News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

push ah

Started by fdig, February 17, 2006, 08:17:50 PM

Previous topic - Next topic

fdig

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

Mark Jones

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!
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Ratch

fdig,

     Or the following.  Ratch


MOVZX ECX,AH
PUSH ECX

zcoder

Or if nothing is in AL
       PUSH EAX


Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names

arafel

how about:

sub     esp, 4
mov     [esp], byte ptr ah


:wink

zooba

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

arafel

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.

zooba

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

fdig

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 ;)

MichaelW

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.

eschew obfuscation