-
Notifications
You must be signed in to change notification settings - Fork 2
/
ASM.INC
152 lines (127 loc) · 3.62 KB
/
ASM.INC
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
;-----------------------------------------------------------------
; asm.inc
; -------
; Standard macros for DPaint II MS-DOS ".asm" files.
;-----------------------------------------------------------------
;-----------------------------------------------------------------
; Memory model configuration.
;-----------------------------------------------------------------
LPROG equ 1 ; 1 means large (>64k) program segment
LDATA equ 0 ; 1 means large (>64k) data segment
;-----------------------------------------------------------------
; After a standard procedure entry (push bp, mov bp,sp), the first
; parm on the stack can be accessed at ARGB[bp].
;-----------------------------------------------------------------
if LPROG
ARGB equ 6
else
ARGB equ 4
endif
;-----------------------------------------------------------------
; File header: sets up groups, segment names, etc.
;-----------------------------------------------------------------
if LPROG
HEADER macro module
module&_TEXT segment word public 'CODE'
module&_TEXT ends
_DATA segment word public 'DATA'
_DATA ends
CONST segment word public 'CONST'
CONST ends
_BSS segment word public 'BSS'
_BSS ends
DGROUP group CONST, _BSS, _DATA
assume cs:module&_TEXT, ds:DGROUP, ss:DGROUP, es:DGROUP
endm
else
HEADER macro
_TEXT segment word public 'CODE'
_TEXT ends
CONST segment word public 'CONST'
CONST ends
_BSS segment word public 'BSS'
_BSS ends
_DATA segment word public 'DATA'
_DATA ends
DGROUP group CONST, _BSS, _DATA
assume cs:_TEXT, ds:DGROUP, ss:DGROUP, es:DGROUP
endm
endif
;-----------------------------------------------------------------
; Data segment start & end.
;-----------------------------------------------------------------
DSEG macro
_DATA segment
endm
;-----------------------------------------------------------------
ENDDS macro
_DATA ends
endm
;-----------------------------------------------------------------
; Program segment start & end.
;-----------------------------------------------------------------
if LPROG
PSEG macro module
module&_TEXT segment
endm
else
PSEG macro
_TEXT segment
endm
endif
;-----------------------------------------------------------------
if LPROG
ENDPS macro module
module&_TEXT ends
endm
else
ENDPS macro module
_TEXT ends
endm
endif
;-----------------------------------------------------------------
; Procedure start & end.
;-----------------------------------------------------------------
STARTPROC macro proc_name
if LPROG
proc_name proc far
else
proc_name proc near
endif
endm
;--- start a procedure and declare it public ---
STARTPROC_PUBLIC macro name
public name
if LPROG
name proc far
else
name proc near
endif
endm
;-----------------------------------------------------------------
ENDPROC macro proc_name
proc_name endp
endm
;-----------------------------------------------------------------
; When the 80286 is in real mode, the POPF instruction may recognize
; a pending maskable interrupt even if interrupts were off before the
; corresponding PUSHF. This macro should be used instead of POPF.
; See "IBM Personal Computer Seminar Proceedings" v2, #4 (September '84)
; for info about the POPF bug.
;-----------------------------------------------------------------
popflags macro
jmp $+3 ; jump around IRET
iret ; pop CS, IP, and flags
push cs
call $-2 ; call within segment
endm
;-----------------------------------------------------------------
; Offsets to low byte & high byte of a word.
;-----------------------------------------------------------------
LO = 0
HI = 1
;-----------------------------------------------------------------
; --- miscellaneous constants
TRUE equ 1
FALSE equ 0