Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .data
- enter db 13
- buf dw 0
- ch_cou dw 1
- num dw 0
- ostatok db 0
- .code
- n:
- push cs
- pop ds
- xor bx, bx ; bx = 0
- push 0b ; stack += 0
- ; start input
- input:
- mov ah, 01h ; enter symbol mode
- int 21h ; interrupt
- cmp al, enter ; compare entered symbol
- je end_input ; if enter
- mov dl, 30h ; dl = 30h
- sub al, dl ; al -= 30h
- mov bl, al ; bl = al
- pop ax ; from stack to ax
- mov dl, 10 ; dl = 10
- mul dl ; ax *= dl
- add ax, bx ; ax += bx
- push ax ; add ax to stack
- jmp input ; loop
- end_input:
- ;zadanie
- xor dx, dx ; dx = 0
- pop ax ; from stack to ax
- mov bx, 10 ; bx = 10
- div bx ; ax /= bx
- mov num, ax ; num = ax
- mov ostatok, dl ; ostatok = dl
- ; start output
- mov ah, 02h ; out symbol mode
- mov dl, 10 ; space symbol
- int 21h ; interrupt
- mov ax, num ; ax = num
- output:
- cmp ax, 0 ; ax ?= 0
- je end_output ; if = 0 go to end
- xor dx, dx ; dx = 0
- mov bx, 10 ; bx = 10
- div bx ; ax /= 10
- mov bx, 30h ; bx = 30h
- add dx, bx ; dx += 30h
- inc ch_cou ; ch_cou++
- push dx ; add dx to stack
- jmp output ; loop
- end_output:
- mov cx, ch_cou ; cx = ch_cou
- out_stack:
- mov ah, 02h ; out symbol mode
- pop bx ; bx = value from stack
- mov dl, bl ; dl = bl
- int 21h ; interrupt
- loop out_stack ; loop
- mov ah, 02h ; out symbol mode
- mov dl, 32 ; dl = space
- int 21h ; interrupt
- mov ah, 02h ; out symbol mode
- mov dl, ostatok ; dl = ostatok
- mov bl, 30h ; bl = 30h
- add dl, bl ; dl += bl
- int 21h ; interrupt
- mov ax, 4c00h
- int 21h
- end N
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement