Hi,
why i cannot push byte registers (ah) on stack?
Here's what ml.exe assembler says:
error A2149: byte register cannot be first operand
greetings
Hello Fdig. AH is a BYTE and the stack in 32-bit windows is comprised of DWORD values, hence the two are incompatible. If you must push AH, try this:
xor ecx,ecx
mov cl,ah
push ecx
Is this for DOS assembly or WIN32 assembly?
Try looking in the ASMINTRO.HLP file - very useful stuff in there. Have Fun!
fdig,
Or the following. Ratch
MOVZX ECX,AH
PUSH ECX
Or if nothing is in AL
PUSH EAX
Zcoder....
how about:
sub esp, 4
mov [esp], byte ptr ah
:wink
Quote from: arafel on February 17, 2006, 11:21:37 PM
how about:
sub esp, 4
mov [esp], byte ptr ah
:wink
Doesn't necessarily mean the rest of the value is clear:
push 0
mov [esp], ah
:U
Quote from: zooba on February 18, 2006, 01:17:35 AM
Doesn't necessarily mean the rest of the value is clear:
Well, no one mentioned the necessity for the whole dword to be cleared. Original intent was to store a single byte on the stack, presumably for later extraction of the same
single byte.
Quote from: arafel on February 18, 2006, 02:03:01 AM
Quote from: zooba on February 18, 2006, 01:17:35 AM
Doesn't necessarily mean the rest of the value is clear:
Well, no one mentioned the necessity for the whole dword to be cleared. Original intent was to store a single byte on the stack, presumably for later extraction of the same single byte.
Fair point. However, it does mean that EAX can be popped and the value is zero-extended already :bg
Quote from: Mark Jones on February 17, 2006, 08:24:49 PM
Hello Fdig. AH is a BYTE and the stack in 32-bit windows is comprised of DWORD values, hence the two are incompatible.
Hi, Ah ok!
Quote
Is this for DOS assembly or WIN32 assembly?
DOS assembly.
Thx for the many answers ;)
MASM returns an error because the processor does not support pushing (or popping) a byte-size register or memory operand, regardless of the stack address size.