Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'emu8086.inc'
- org 100h ; set location counter to 100h
- main proc
- call scanf
- mov ax, cx
- call printf
- mov ax, cx
- call printf
- main endp
- ret
- printf proc
- push ax
- push cx
- push bx
- push dx
- mov bl, 0
- mov cx, 10
- PrintLoopStart:
- mov dx, 0
- div cx
- add dx, 48
- push dx
- add si, 2
- add bl, 2
- cmp ax, 0
- jne PrintLoopStart
- SecondLoopStart:
- pop dx
- mov ah, 2
- int 21h
- sub bl, 2
- cmp bl, 0
- jne SecondLoopStart
- mov ah, 2
- mov dl, 0ah
- int 21h
- mov dl, 0dh
- int 21h
- pop dx
- pop bx
- pop cx
- pop ax
- ret
- printf endp
- scanf proc
- push ax
- push bx
- push dx
- mov cx, 0
- ScanLoopStart:
- mov ah, 1
- int 21h
- mov ah, 0
- cmp al, 48
- jl Exit
- cmp al, 57
- jg Exit
- mov bx, cx
- shl bx, 1
- shl cx, 3
- add cx, bx
- sub ax, 48
- add cx, ax
- cmp ax, -1
- jne ScanLoopStart
- Exit:
- mov ah, 2
- mov dl, 0ah
- int 21h
- mov dl, 0dh
- int 21h
- pop dx
- pop bx
- pop ax
- ret
- scanf endp
- DEFINE_PRINT_STRING
- DEFINE_SCAN_NUM
- DEFINE_PRINT_NUM
- DEFINE_PRINT_NUM_UNS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement