Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; You may customize this and other start-up templates;
- ; The location of this template is c:\emu8086\inc\0_com_template.txt
- org 100h
- .stack
- .data
- count db 0
- res db 0
- nl db 0dh, 0ah, '$'
- .code
- onem macro x
- push ax
- mov dx, x
- mov ah, 2
- add dl, '0'
- int 21h
- pop ax
- endm onem
- newl macro
- mov ah, 9
- lea dx, nl
- int 21h
- endm newl
- proc main
- mov dx, @data
- mov ds, dx
- call inputAX
- newl
- mov ah, 0
- mov al, res
- ;mov al, 'a'
- ;mov ax, 12345
- call printAX
- mov ah, 4ch
- int 21h
- endp main
- inputAX proc
- mov ax, 0
- mov bl, 10
- inputloop:
- mov ah, 1
- int 21h
- cmp al, 0dh
- je doneinput
- sub al, '0' ; ascii -> value
- mov dl, al ; new input
- mov al, res ; al = res
- mul bl ; al = res * 10
- mov res, al
- add res, dl ; al = res + new digit
- jmp inputloop
- doneinput:
- mov al, res
- ret
- endp inputAX
- printAX proc
- mov bx, 10
- L1:
- xor dx, dx
- div bx ; DX = AX 10, AX = AX/10
- push dx
- inc count
- cmp ax, 0
- je L2
- jmp L1
- L2:
- dec count
- pop dx
- onem dx
- cmp count, 0
- je done
- jmp L2
- done:
- ret
- endp printAX
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement