-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQDOS.ASM
147 lines (121 loc) · 3.39 KB
/
QDOS.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
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
; Copyright 1990-2021, Jerome Shidel
; Released Under Mozilla Public License 2.0
; This project and related files are subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this file, You
; can obtain one at http://mozilla.org/MPL/2.0/.
; QCrt 9.1
; For DOS, Nasm and Pascal 16-bit edition.
; This assembly language library uses the pascal calling convention. All calls
; are far calls. Data parameters passed to procedure and functions are pushed
; onto the stack in reverse order and are popped automatically by the function
; or procedure on their return. Simple function return values are usually set
; in AL, AX or in the DX:AX pair. DS, SS, SP, BP are preserved. However, the
; state of all other registers are not guaranteed. So, if calling this library
; from a language other than Pascal, such as from more assembly code, you must
; take care of preserving any registers and values you wish to retain yourself!
%idefine QCrt 9.1 - QDOS
%ifndef TargetOS
%idefine TargetOS DOS
%endif
%ifndef TargetCPU
%idefine TargetCPU 8086
%endif
%ifndef QDefines
%include "QDEFINES.INC"
%endif
%ifidni __OUTPUT_FORMAT__, bin
jmp SkipOverQDOS
%endif
; Internal Data Segment
section Section_DATA
%ifidn __OUTPUT_FORMAT__, obj
ProgramPrefixSeg:
dw 0 ; Program prefix segment
UnitDataSeg:
dw 0 ; Data Segment
%imacro PrefixSeg 1
%ifidni %1, ax
mov ax, [ProgramPrefixSeg]
%else
push ax
mov ax, [ProgramPrefixSeg]
pop ax
%endif
%endmacro
%imacro DataSeg 1
%ifidni %1, ax
mov ax, [UnitDataSeg]
%else
push ax
mov ax, [UnitDataSeg]
pop ax
%endif
%endmacro
section Section_SHARED
%else
%endif
section Section_CODE
; ------------------- Internal Functions; Don't call them directly !!!!
%ifidni __OUTPUT_FORMAT__, bin
SearchEnvTable:
pushy ax, bx, di
cld
PrefixSeg es
mov es, [es:0x2c]
mov si, 0x0000
mov bx, di
.Compare:
mov di, bx
.CompareLoop:
mov ah, [di]
inc di
cmp ah, 0x00
je .Maybe
es lodsb
cmp al, 0x00
je .NotFound
cmp al, ah
je .CompareLoop
.Mismatch:
cmp al, 0x00
je .Compare
es lodsb
jmp .Mismatch
.Maybe:
es lodsb
cmp al, 0x00
je .NotFound
cmp al, '='
jne .Mismatch
.Found:
clc
jmp .Done
.NotFound:
stc
.Done:
poppy di, bx, ax
ret
%endif
; ------------------- Exported Functions
; function InitQDOS(PSP : word) : boolean; external;
xfunction InitQDOS, boolean, 2
mov ax, [STACKBP + 0]
mov [ProgramPrefixSeg], ax
mov [UnitDataSeg], ds
PrefixSeg ax
cmp ax, 0x0000
je .Error
.AOkay:
mov al, TRUE
jmp .Done
.Error:
mov al, FALSE
.Done:
xret
xprocedure DoneQDOS
xret
SkipOverQDOS:
%ifidni __OUTPUT_FORMAT__, bin
%warning Auto-initialize QuickDOS routines.
pushcall InitQDOS
%endif