-
Notifications
You must be signed in to change notification settings - Fork 1
/
UMB.ASM
113 lines (75 loc) · 1.09 KB
/
UMB.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
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
Ideal
include 'tsrid.inc'
P286
Model tiny
Locals
Group MyCode Code2
Segment Code2 word public 'Code'
Assume cs:MyCode, ds:MyCode
PUBLIC AllocateUMB, FreeUMB
oldLink DB 0
oldStrategy DW 0
PROC UMBLink near
Pushf
Push ax bx
Mov ax, 5802h
Int 21h
Mov [cs:oldLink], al
Mov ax, 5800h
Int 21h
Mov [cs:oldStrategy], ax
Mov ax, 5803h
Mov bx, 1
Int 21h
Mov ax, 5801h
Mov bx, 80h
Int 21h
Pop bx ax
Popf
Ret
ENDP UMBLink
PROC UMBUnLink near
Pushf
Push ax bx
Mov ax, 5803h
Xor bx, bx
Mov bl, [cs:oldLink]
Int 21h
Mov ax, 5801h
Mov bx, [cs:oldStrategy]
Int 21h
Pop bx ax
Popf
Ret
ENDP UMBUnLink
PROC AllocateUMB near ;INPUT: bx - size in para
;OUT: ax - segment if carry=0
Call UMBLink
Push bx
Mov ah, 48h
Int 21h
Jnc @@ex
Mov ax, 5801h
Xor bx, bx
Int 21h
Pop bx
Mov ah, 48h
Int 21h
Call UMBUnLink
Ret
@@ex:
Call UMBUnLink
Add sp, 2
Ret
ENDP AllocateUMB
PROC FreeUMB near ;INPUT: es - segment
Call UMBLink
Push ax
Mov ah, 49h
Int 21h
Pop ax
Call UMBUnLink
Ret
ENDP FreeUMB
ENDS Code2
END