114 lines
1011 B
NASM
114 lines
1011 B
NASM
|
INCLUDE dos_layer.asm
|
||
|
|
||
|
|
||
|
org 0x100
|
||
|
mov sp,#STACK
|
||
|
|
||
|
MOV AX,#0x1
|
||
|
MOV BX,#0x1
|
||
|
|
||
|
CALL PRINT_HEX
|
||
|
|
||
|
push bx
|
||
|
MAIN_LOOP:
|
||
|
pop bx
|
||
|
|
||
|
CALL PRINT_HEX
|
||
|
|
||
|
push AX
|
||
|
ADD AX,BX
|
||
|
|
||
|
JNC MAIN_LOOP
|
||
|
pop bx
|
||
|
|
||
|
MOV AH,#0x02
|
||
|
MOV DL,#0x0a
|
||
|
INT #0x21
|
||
|
|
||
|
hlt
|
||
|
|
||
|
|
||
|
|
||
|
;Input AX
|
||
|
PRINT_HEX:
|
||
|
PUSH DX
|
||
|
|
||
|
TEST AH,#0xF0
|
||
|
jz NOT_FIRST_NIBBLE
|
||
|
MOV DL,AH
|
||
|
CALL PRINT_HIGH
|
||
|
JMP SKIP1
|
||
|
|
||
|
NOT_FIRST_NIBBLE:
|
||
|
TEST AH,#0x0F
|
||
|
jz NOT_SECOND_NIBBLE
|
||
|
SKIP1:
|
||
|
MOV DL,AH
|
||
|
CALL PRINT_LOW
|
||
|
JMP SKIP2
|
||
|
|
||
|
NOT_SECOND_NIBBLE:
|
||
|
TEST AL,#0xF0
|
||
|
jz NOT_THIRD_NIBBLE
|
||
|
SKIP2:
|
||
|
MOV DL,AL
|
||
|
CALL PRINT_HIGH
|
||
|
|
||
|
NOT_THIRD_NIBBLE:
|
||
|
MOV DL,AL
|
||
|
CALL PRINT_LOW
|
||
|
|
||
|
PUSH AX
|
||
|
MOV AH,#0x02
|
||
|
MOV DL,#0x20
|
||
|
INT #0x21
|
||
|
POP AX
|
||
|
|
||
|
POP DX
|
||
|
RET
|
||
|
|
||
|
PRINT_HIGH:
|
||
|
AND DL,#0xF0
|
||
|
TEST DL,#0x80
|
||
|
jz NOT1
|
||
|
OR DL,#0x08
|
||
|
NOT1:
|
||
|
TEST DL,#0x40
|
||
|
jz NOT2
|
||
|
OR DL,#0x04
|
||
|
NOT2:
|
||
|
TEST DL,#0x20
|
||
|
jz NOT3
|
||
|
OR DL,#0x02
|
||
|
NOT3:
|
||
|
TEST DL,#0x10
|
||
|
jz DONE
|
||
|
OR DL,#0x01
|
||
|
DONE:
|
||
|
|
||
|
PRINT_LOW:
|
||
|
PUSH AX
|
||
|
AND DL,#0x0F
|
||
|
CMP DL,#0x0A
|
||
|
JNS LETTERS
|
||
|
ADD DL,#0x30
|
||
|
MOV AH,#0x02
|
||
|
INT #0x21
|
||
|
POP AX
|
||
|
RET
|
||
|
|
||
|
LETTERS:
|
||
|
ADD DL,#0x37
|
||
|
MOV AH,#0x02
|
||
|
INT #0x21
|
||
|
POP AX
|
||
|
RET
|
||
|
|
||
|
.BLKB 200
|
||
|
STACK:
|
||
|
|
||
|
.ORG 0xFFF0
|
||
|
MOV AX,#0x0100
|
||
|
JMP AX
|
||
|
|