-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathI286.ASM
72 lines (70 loc) · 1.88 KB
/
I286.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
; Copyright (c) 1990,1991,1992 Chris and John Downey
.286P
I286_TEXT segment word public 'CODE'
db "@(#)i286.asm 2.1 (Chris & John Downey) 7/29/92"
db 0
;***
;
; program name:
; xvi
; function:
; PD version of UNIX "vi" editor, with extensions.
; module name:
; i286.asm
; module function:
; Low-level 80286-specific routines for OS/2 version.
; history:
; STEVIE - ST Editor for VI Enthusiasts, Version 3.10
; Originally by Tim Thompson (twitch!tjt)
; Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
; Heavily modified by Chris & John Downey
;
;***
public _es0
public _newstack
;
; void far es0(void);
;
; Set the ES register to 0. Microsoft say this should be done
; before calling the OS/2 DosCreateThread() system call but, as
; far as I can see, they don't provide any C library function or
; compiler directive or any other easy way of doing it. So, if
; you want to write multi-thread code for OS/2, you just have to
; be an assembler hacker.
;
_es0 proc far
xor ax, ax
mov es, ax
ret
_es0 endp
;
; unsigned char far * far newstack (int sub);
;
; This is utterly disgusting, but unavoidable. The fault lies
; with the design of OS/2, & the lack of provision for multiple
; stacks in Microsoft's high-level language products.
;
; We need the provision for multiple stacks because we are
; running multiple threads, but some Microsoft library functions
; are evidently compiled with stack probes, which give spurious
; stack overflow errors if we use multiple stacks. So we just
; use some space at the bottom of our default (48 kb) stack. The
; return value we want here is the top of the new stack, & we
; obtain it simply by subtracting the sub parameter from the
; stack pointer.
;
_newstack proc far
mov bx, sp
;
; Return offset in AX.
;
mov ax, sp
sub ax, word ptr ss:[bx + 4]
;
; Return stack segment in DX.
;
mov dx, ss
ret
_newstack endp
I286_TEXT ends
end