News:

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

help me about highword

Started by boydtbk, June 07, 2010, 12:27:24 PM

Previous topic - Next topic

boydtbk

I'm using MASM32 SDK verison 10, and I have a problem with highword:

            val dd 10101011b
            mov val, HIGHWORD val


error A2105: HIGH and LOW require immediate operands
Can some body help me?

dedndave

i have never used HIGHWORD
but, you can't do memory to memory MOV that way
try getting the value into a register first
        movzx   eax,word ptr val+2   ;same as HIGHWORD ?
        mov word ptr val,ax

i think that's what you are trying to do   :P

boydtbk

and about lowword ? I don't know exactly what I have to do. Can you show me ?

jj2007

movzx   eax, word ptr val is the low word
movzx   eax, word ptr val+2 is the high word

GregL

#4
boydtbk,

I prefer to write it as


movzx   eax, word ptr val+0  ;is the low word
movzx   eax, word ptr val+2  ;is the high word


just for clarity.



clive

The typical usage for LOWWORD/HIGHWORD is as follows

= DEADBEEF val     EQU     0DEADBEEFh

0000  B8 BEEF         mov     ax,LOWWORD val
0003  BA DEAD         mov     dx,HIGHWORD val


They are designed to handle immediate values (ie EQU, or simple constants/math)

As for style, I'd prefer this if you are pulling high/low values from memory


value  dd  0DEADBEEFh
;...
movzx   eax, word ptr value[0] ; is the low word
movzx   edx, word ptr value[2] ; is the high word
It could be a random act of randomness. Those happen a lot as well.