Reputation: 89
I am new to assembly. I want to do a subroutine and I need to follow the convention. The caller put the value in register then you push to the stack. In subroutine you need to extract from the stack but I have some problem. Here is my code:
.286
.model huge
.stack 100h
mov bl, 'd' ; just put d to test
push bx
call putch
call terminate
; ---------- void putch(char c) ----------
putch:
; Print character into screen
; bl <- character to be printed
mov bx, [sp+4] ; THIS IS THE ERROR.
mov dl, bl ; store the argument into dl
mov ah, 2h ; print the character
int 21h
ret 4 ; return
; ---------- end of function ----------
terminate:
mov ah, 4ch ; terminate the program
int 21h
END start
My prof said you use mov bx, [sp+offset]
to get the value from stack but it doesn't compile. I use 286 assembly. Anyone have a solution?
Upvotes: 1
Views: 87
Reputation: 39411
This does not exist mov bx, [sp+offset]
on 286 assembly.
You can use
mov bp,sp
mov bx,[bp+offset]
Upvotes: 1