-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUTILS.ASM
72 lines (52 loc) · 2.01 KB
/
UTILS.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
include GLOBALS.INC
code segment para public 'CODE' use16
assume cs:code
; =============== S U B R O U T I N E =======================================
; atoi, string stored in al
atoi proc near ; CODE XREF: start+202p start+223p ...
xor ax, ax ; reset ax
mov bl, 0Ah ; bl = 10
or cx, cx ; test cx
again: ; CODE XREF: atoi+22j
jz short atoireturn ; return if cx == 0
mov bh, es:[di] ; load dest char
cmp bh, 30h ; '0'
jb short atoireturn ; bail if less than '0'
cmp bh, 39h ; '9'
ja short atoireturn ; bail if bigger than '9'
sub bh, 30h ; '0' ; bh now binary of nr
mul bl ; ax = 10 * al
add al, bh ; al += bh
jnb short leaveAL
mov al, 0
leaveAL: ; CODE XREF: atoi+1Cj
inc di
dec cx
jmp short again
; ---------------------------------------------------------------------------
atoireturn: ; CODE XREF: atoi:againj atoi+Ej ...
retn
atoi endp
; =============== S U B R O U T I N E =======================================
conprintln proc near ; CODE XREF: start+CEp start+122p ...
call conprint
lea si, demoFileName
call conprint
lea si, crlf ; "\r\n"
conprintln endp ; sp-analysis failed
; =============== S U B R O U T I N E =======================================
conprint proc near ; CODE XREF: start+111p conprintlnp ...
mov dl, [si]
or dl, dl
jz short hitZeroTerm
inc si
mov ah, 2
int 21h ; DOS - DISPLAY OUTPUT
; DL = character to send to standard output
jmp short conprint
; ---------------------------------------------------------------------------
hitZeroTerm: ; CODE XREF: conprint+4j
retn
conprint endp
code ends
end