News:

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

mov eax

Started by oex, April 01, 2010, 01:22:11 AM

Previous topic - Next topic

oex

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
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

raymond

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.)
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

dedndave

        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

drizz

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


The truth cannot be learned ... it can only be recognized.

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

oex

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
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

yes - Drizz's method with "AND 0FF00FFh" is nice and clean   :U

oex

heh just read your post properly dave.... cleaner still :lol

mov eax, 620061h
mov [edi], eax
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

        mov dword ptr [edi],620061h   ;'a',0,'b',0
:P

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv