flat assembler
Message board for the users of flat assembler.
Index
> Main > Immediate argument extension |
Author |
|
Tomasz Grysztar 07 Mar 2006, 13:39
fasm by default generates the shorter code (the one with imm8), unless you force the full 16-bit immediate size by writing ADD BX, WORD 0x20.
|
|||
07 Mar 2006, 13:39 |
|
CodeX 07 Mar 2006, 13:52
Yes, you're right. It works fine for 0x20, but doesn't work for 0xFF. It still generates extra zeroes.
|
|||
07 Mar 2006, 13:52 |
|
MazeGen 07 Mar 2006, 14:39
As you said, imm8 is sign-extended, so this "sign extension" feature can't work for ADD BX, 0xFF (0x00FF), because it would be ADD BX, 0xFFFF then.
|
|||
07 Mar 2006, 14:39 |
|
CodeX 07 Mar 2006, 14:59
1. "Intel says" it should work, though it produces the same result as SUB BX, 1 with reduced command length
2. "Intel says" it should also work with such commands as XOR, like XOR BX, 0xE8, giving the same result as XOR BX, 0xFFE8 but one byte shorter (3 bytes shorter with EBX). And I can't replace this command with anything else having the same result and the same length. Or is it just my wrong interpretation of what does "Intel say"? |
|||
07 Mar 2006, 14:59 |
|
LocoDelAssembly 07 Mar 2006, 15:34
CodeX wrote: XOR BX, 0xE8, giving the same result as XOR BX, 0xFFE8 but one byte shorter (3 bytes shorter with EBX). "XOR BX, 0xE8" only affects the bits in BL and "XOR BX, 0xFFE8" affects BH and BL.Clearly it isn't for far the same. [edit]Sorry, I misunderstood what you said?[/edit] Last edited by LocoDelAssembly on 07 Mar 2006, 16:05; edited 1 time in total |
|||
07 Mar 2006, 15:34 |
|
Tomasz Grysztar 07 Mar 2006, 15:57
When you write "XOR BX, 0xFFE8" fasm generates the shortened form, just like you need. Same with "ADD BX,0FFFFh" and "ADD BX,-1". And "SUB BX,1" will be short form also, so there is no advantage in using "ADD BX,-1" instead of it.
|
|||
07 Mar 2006, 15:57 |
|
CodeX 07 Mar 2006, 17:39
Cool
|
|||
07 Mar 2006, 17:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.