-
Notifications
You must be signed in to change notification settings - Fork 0
/
oct_ops.asm
72 lines (66 loc) · 1.05 KB
/
oct_ops.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
; Reads oct digit
; Result : AL
READ_OCT_DIGIT PROC NEAR
OCT_DIGIT:
READ
CMP AL,30H
JL OCT_DIGIT
CMP AL,37H
JG OCT_DIGIT
PRINT AL
SUB 30H
RET
READ_OCT_DIGIT ENDP
; Reads a n-digit oct where n = DL
; Result : BX
; Modifies all registers
; READ_OCT_DIGIT is required
READ_N_DIGIT_OCT PROC NEAR
MOV BX,0
N_DIGIT_OCT:
MOV CL,3
ROL BX,CL
CALL READ_OCT_DIGIT
ADD BL,AL
DEC DL
CMP DL,00H
JG N_DIGIT_OCT
RET
READ_N_DIGIT_OCT ENDP
; Prints a 5-digit oct number
; Takes the number from CX
; Modifies AX,BX,DX
PRINT_OCT PROC NEAR
MOV BX,CX
AND CX,07000H
ROR CH,1
ROR CH,1
ROR CH,1
ROR CH,1
ADD CH,30H
PRINT CH
MOV CX,BX
AND CX,0E00H
ROR CH,1
ADD CH,30H
PRINT CH
MOV CX,BX
AND CX,01F0H
ROL CX,1
ROL CX,1
ADD CH,30H
PRINT CH
MOV CX,BX
AND CX,0038H
ROR CL,1
ROR CL,1
ROR CL,1
ADD CL,30H
PRINT CL
MOV CX,BX
AND CX,07H
ADD CL,30H
PRINT CL
MOV CX,BX
RET
PRINT_OCT ENDP