Reputation:
How to read from stack without popping? I tried this:
mov dx, [ss:sp]
and got an error: "error: invalid effective address"
I'm using NASM and my program is 16-bit for DOS.
Upvotes: 0
Views: 398
Reputation: 58782
16 bit addressing doesn't support [sp]
you can only address using a limited combination of bx
, bp
, si
, di
and an displacement. That means you have to move sp
to one of the aforementioned registers, the usual one being bp
which even has the ss
segment associated as default. Function prologue typically sets this up, so you can access your parameters and locals easily:
push bp
mov bp, sp
...
mov dx, [bp + displacement]
Upvotes: 2