I am trying to learn some Assembler code; specifically how to use the stack and how it works, etc. However, I run into an error when I use the code below:
entry:
push 0x42
call teststack
jmp hang
hang:
jmp hang
teststack:
mov ah, 0x0e
pop al
mov bh, 0x00
mov bl, 0x04
mov cx, 0x01
int 10h
ret
What I am trying to do is pass the number 42 (life, universe, everything :D) into my teststack procedure, where it will print Ascii 0x42 (I think capital B).
My issue is a compiler error, for the line that reads pop al:
**error: invalid combination of opcode and operands**
I am using NASM inside a Windows 98 virtual machine.
Any help with my error would be greatly appreciated.
Didn’t ever use NASM but I presume that you are in 16 bit mode and pop is by default using 16 bit registers, so you can’t use ah. When you pushed 0x42 to stack that was a 16 bit value (0x0042). It’s safe to use pop ax and then set ah :