]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DEV/SMARTDRV/AB_MACRO.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / DEV / SMARTDRV / AB_MACRO.ASM
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;
3 ; MACRO definitions for expanded memory manager
4 ;
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;
7 ; 1. MACRO to save mapping context in case somebody else has
8 ; mapped the page registers.
9 ;
10 save_mapping_context macro
11 local save_agn_m,save_err_m,save_ok_m,save_exit_m
12 ;
13 ; the save mapping call for the above board -->
14 ;
15 ; mov ah,47h
16 ; mov dx,handle
17 ; int 67h
18 ;
19 ; on return ax = 0 signifies success
20 ;
21 ;
22 push ax ; save registers
23 push dx
24 ;
25 ; set up emm registers and execute call to save mapping context
26 ;
27 save_agn_m:
28 mov dx,cs:[above_pid] ; get emm handle
29 mov ah,above_save_map_pid ; save map call
30 int 67h ; call the manager
31 or ah,ah ; is there an error?
32 jz save_ok_m ; if not we are done
33 ;
34 ; error in saving mapping context, check for error
35 ;
36 cmp ah,above_error_busy ; if the emm manager was busy
37 jz save_agn_m ; we would like to try again
38 ;
39 ; unrecoverable error, indicate error type in al
40 ;
41 pop dx
42 pop dx ; pop the regs off the stack
43 ;
44 mov al,0aah ; drive not ready
45 cmp ah,above_error_cntxt_no_stack ;
46 jz save_err_m
47 cmp ah,above_error_second_save ;
48 ja save_err_m
49 mov al,0bbh ; general failure
50 save_err_m:
51 stc
52 jmp short save_exit_m
53 save_ok_m:
54 clc
55 pop dx
56 pop ax ; restore registers
57 save_exit_m:
58 endm
59 ;
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
61 ;
62 ; 2. MACRO to restore the mapping context saved earlier
63 ;
64 restore_mapping_context macro
65 local rest_agn_m, rest_ok_m, rest_exit_m
66 ;
67 ; the restore above map call -->
68 ;
69 ; mov ah,48h
70 ; mov dx,handle
71 ; int 67h
72 ; ah = 0 is success
73 ;
74 ;
75 push ax
76 pushf
77 ;
78 rest_agn_m:
79 mov dx,cs:[above_pid] ; get emm handle
80 mov ah,above_restore_map_pid ; restore map call
81 int 67h ; call manager
82 or ah,ah ; is there any error
83 jz rest_ok_m ; if not go to finish up
84 ;
85 ; error condition, check for recoverable error
86 ;
87 cmp ah,above_error_busy ; if manager was busy
88 jz rest_agn_m ; we sure can try again
89 cmp ah,above_error_no_cntxt ;
90 jz rest_ok_m ; ignore invalid pid error
91 ;
92 ; unrecoverable error
93 ;
94 pop dx
95 pop dx
96 mov al,0bbh ; general failure
97 stc
98 jmp short rest_exit_m
99 ;
100 rest_ok_m:
101 popf
102 pop ax
103 rest_exit_m:
104 ;
105 endm
106 ;
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 ;
109 ; 3. MACRO to map a page in the physical page map onto a logical
110 ; page.
111 ;
112 ; the map above page requires
113 ; mov ah,44h
114 ; mov dx,handle
115 ; mov al,physical_page# (0-3)
116 ; mov bx,logical_page#
117 ; int 67H
118 ; ah = 0 success and this routine zaps ax,dx and bx
119 ;
120 map_page macro
121 local map_agn_m,map_exit_m,map_fin_m
122 ;
123 mov ah,above_map ; function map page
124 mov dx,cs:[above_pid] ; get emm handle
125 ;
126 push ax
127 ;
128 map_agn_m:
129 pop ax
130 push ax
131 push bx
132 push dx ; "damn call above_map zaps these registers"
133 ;
134 int 67h ; map call
135 pop dx
136 pop bx
137 ;
138 or ah,ah ; is there an error?
139 jz map_fin_m ; if not go to finish up
140 ;
141 ; error condition - check for recoverable error
142 ;
143 cmp ah,above_error_busy ; if manager was busy
144 jz map_agn_m ; we sure can try again
145 ;
146 ; unrecoverable error
147 ;
148 pop ax
149 mov al,0aah ; device not ready error
150 stc
151 jmp short map_exit_m
152 ;
153 ; exit point
154 ;
155 map_fin_m:
156 clc
157 pop ax
158 map_exit_m:
159 ;
160 endm
161 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
162 ;
163 ; OTHER MACROS
164 ;
165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166 ;
167 ; 1) MACRO to switch es:di with ds:si
168 ;
169 src_dest_switch macro
170 ;
171 push ds
172 push es
173 push si
174 mov si,di
175 pop di
176 pop ds
177 pop es
178 ;
179 endm
180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;