我尝试编写一个获取字符串并将其复制到堆栈上的过程。
那是我的代码:
cpyStr proc
mov bp, sp
; save the IP
mov bx, sp
; copy the counter loop
mov cx, [bp+4]
; make local variable - need 30 bytes
sub sp, [bp+4] * 2; length is byte so duplicate for word ...
; copy the string's offset
mov si, [bp+2] ; offset to si
copy:
sub bx, 2 ; next word
mov ax, [si] ; store the character in ax
mov [bp], ax ; copy to stack's currect word
; to the next ..
add si, 1 ; go to next character
loop copy
; print
push bx ; send local string var as parameter for printStr
call printStr
; return the IP
push bx
; returtn to main ....
ret 4 ; delete 2 parameters
endp ; end
主要的:
start:
mov ax,@DATA
mov ds,ax
; print
push strSize
push offset string
call cpyStr
; msg
push offset passed
call printStr
; end
mov ah,4ch
mov al,0
int 21H
end start
数据段:
string db "Heello$"
strSize dw 8
passed db "Passed$"
由于某种原因,它没有成功处理。