Created
January 18, 2018 14:38
-
-
Save Ionizing/63f50bb36f6df695b9ca30b08af1db8e to your computer and use it in GitHub Desktop.
王爽《汇编语言》实验十(3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assume cs:code, ss:stack, ds:data | |
data segment | |
dd 10h dup (0) | |
data ends | |
stack segment | |
dd 10h dup (0) | |
stack ends | |
code segment | |
start: | |
mov ax, stack | |
mov ss, ax | |
mov sp, 40h | |
mov ax, 12666 | |
mov bx, data | |
mov ds, bx | |
mov si, 0 | |
mov di, si | |
call dtoc | |
mov dh, 8 | |
mov dl, 3 | |
mov cl, 2 | |
call show_str | |
mov ah, 4ch | |
int 21h | |
dtoc: ;push si | |
mov bx, 10 | |
mov dx, 0 | |
mov ch, 0 | |
change: | |
div bx | |
add dx, 30h | |
mov byte ptr ds:[si], dl | |
mov dx, 0 | |
;push ax | |
mov cl,al | |
jcxz ok_convert | |
inc si | |
jmp change | |
ok_convert: | |
;pop si | |
;push si | |
mov si, di | |
mov ax, 0 | |
push ax | |
reverse_push: | |
mov al, ds:[si] | |
mov ah, 0 | |
mov cx, ax | |
jcxz ok_rpop | |
push ax | |
inc si | |
jmp reverse_push | |
ok_rpop: | |
mov si, di | |
reverse_pop: | |
pop ax | |
mov byte ptr ds:[si], al | |
mov cx, ax | |
jcxz ok_all | |
inc si | |
jmp reverse_pop | |
ok_all: | |
ret | |
show_str: | |
ret | |
code ends | |
end start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment