flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
acel
I saw this instruction in fasm source, what's the target of this instruction? Usually this op (shl) contains 2 operand, why the target is ignored by fasm?
|
|||
![]() |
|
revolution
Where do you see that?
|
|||
![]() |
|
acel
Sorry for the confusion, the full instruction is actually `mov eax, 1 shl 8`, so shr here is calculated by the assembler instead of being included in the instruction encoding?
|
|||
![]() |
|
LocoDelAssembly
Yes, it is calculated by the assembler (i.e. it assembles `mov eax, 256`).
|
|||
![]() |
|
revolution
In this case SHL is not used as an instruction, it is a numeric operator. The instruction in the above line is actually MOV.
|
|||
![]() |
|
uart777
How about a runtime version? Assembler can resolve constant subexpressions.
Code: macro RGB r, g, b { mov eax, r ; 00.00.00.RR shl eax, 16 ; 00.RR.00.00 mov ecx, g ; 00.00.00.GG shl ecx, 8 ; 00.00.GG.00 or eax, ecx ; 00.RR.GG.00 mov edx, b ; 00.00.00.BB or eax, edx ; 00.RR.GG.BB } |
|||
![]() |
|
uart777
Just to elaborate. Assemblers resolve constant expressions to one immediate value. When you write - add eax, (1+2+3)*2 - assembler sees it as "add eax, 12" and FASM uses the 5 byte instruction: add eax, i32 ; 05 i32
|
|||
![]() |
|
AsmGuru62
Come to think of it - runtime version was never needed for me.
Once the colors are set by default I use the ChooseColor function and it provides a color as 32 bit value, so there was no need to make it from RGB pieces. |
|||
![]() |
|
uart777
AsmGuru: Depends on what you're doing. In art/image/game/graphics software, there are many situations where we need to alter pixels/colors directly and calculate RGBs at runtime using registers and/or memory operands (which your macro won't accept).
|
|||
![]() |
|
AsmGuru62
I understand.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.