The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: oex on April 01, 2010, 01:22:11 AM

Title: mov eax
Post by: oex on April 01, 2010, 01:22:11 AM
It is possible to do this:

mov eax, 'abgr'

but can I do this somehow?

mov eax, 'a',0,'b',0

or even

mov eax, 97,0,98,0
Title: Re: mov eax
Post by: raymond on April 01, 2010, 02:29:22 AM
No. The instruction expects a single value to be loaded into EAX.

However, similar to "mov eax,5", you could do
mov eax,"r"
such that AL would contain "r", and the upper 24 bits of EAX would contain 0

(Note that the mov al,"r" instruction would not zero the upper 24 bits of EAX.)
Title: Re: mov eax
Post by: dedndave on April 01, 2010, 02:31:58 AM
        mov     eax,'a',0,'b',0
would be
        mov     eax,620061h
;'a' = 61h, 'b' = 62h

you could probably write a macro to do it with the text defines
Title: Re: mov eax
Post by: drizz on April 01, 2010, 02:53:06 AM
Quote from: oex on April 01, 2010, 01:22:11 AM
but can I do this somehow?

mov eax, 'a',0,'b',0

or even

mov eax, 97,0,98,0

mov eax, ('a' shl 24) or ('b' shl 8)

mov eax, 'abba' and 0FF00FF00h


Title: Re: mov eax
Post by: hutch-- on April 01, 2010, 03:56:09 AM
The register with the MOV mnemonic expects a 32 bit value, how you write an assembler to load it is your own business. FASM loads in 1234 order, MASM in traditional reverse and I have no doubt you could produce other variations but it must enbd up a valid opcode, the rest is style and preference.
Title: Re: mov eax
Post by: oex on April 01, 2010, 12:49:36 PM
Yep nice one dave and drizz.... I like the and method.... So much better than:

mov al, 'a'
mov ah, 'b'
bswap eax
mov al, etc etc

or (and this is shows where this was relevant to me....)

mov al, 'a'
mov [edi], al
mov al, 0
mov [edi+1], al
mov al, 'b'
mov [edi+2], al
mov al, 0
mov [edi+3], al

much cleaner:
mov eax, 'abba' and 0FF00FF00h
mov [edi], eax

This could also be useful for manualy editing unicode for example
Title: Re: mov eax
Post by: dedndave on April 01, 2010, 01:01:58 PM
yes - Drizz's method with "AND 0FF00FFh" is nice and clean   :U
Title: Re: mov eax
Post by: oex on April 01, 2010, 01:05:22 PM
heh just read your post properly dave.... cleaner still :lol

mov eax, 620061h
mov [edi], eax
Title: Re: mov eax
Post by: dedndave on April 01, 2010, 01:13:17 PM
        mov dword ptr [edi],620061h   ;'a',0,'b',0
:P
Title: Re: mov eax
Post by: oex on April 01, 2010, 05:20:30 PM
Awesome, ty :bg