flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > FASM accept negative immediates in ENTER and INT Goto page 1, 2 Next |
Author |
|
revolution 21 Jan 2010, 04:34
Code: retn -4 |
|||
21 Jan 2010, 04:34 |
|
LocoDelAssembly 21 Jan 2010, 04:39
Code: irps instr, ret retn retf { instr -4 } And surely there are more instructions. What do you think, it is OK to allow that? |
|||
21 Jan 2010, 04:39 |
|
revolution 21 Jan 2010, 04:44
LocoDelAssembly wrote: What do you think, it is OK to allow that? |
|||
21 Jan 2010, 04:44 |
|
Madis731 21 Jan 2010, 07:30
Isn't it nitpicking. I've always wondered why is there SUB-instruction when you can perfectly and legally exchange it with negative ADD-instruction, but I don't consider it evil.
add eax,-1 is perfectly okay too. then you have to wonder what algorithmic importance does an xor eax,-4 have? I am opposed to the idea of having FASM decide how we should code. If one's worried about negative horror then its the job of the macros. if imm8<0 then display "Warning: "#imm8#" is not a supported value" etc. |
|||
21 Jan 2010, 07:30 |
|
revolution 21 Jan 2010, 07:47
Madis731: "SUB eax,ebx", How to do with ADD?
"add eax,-1" is okay. Since it is a 2's complement adder. But "retn -4" does not use a 2's complement adder internally. The CPU will do the "wrong" thing if you are expecting "ret / add esp,-4" then you won't get it. |
|||
21 Jan 2010, 07:47 |
|
revolution 21 Jan 2010, 07:55
Code: include 'win32ax.inc' .code begin: repeat 16 sub esp,4092 push eax end repeat pop eax ;esp=esp-65532 call test_retn invoke ExitProcess,0 test_retn: retn -4 .end begin |
|||
21 Jan 2010, 07:55 |
|
hopcode 21 Jan 2010, 08:23
- add eax,-1 is not the problem, no fasm change.
- int -101 not necessary, even if int -3 is not int 3, it is to say, there is no useful internal operation over the imm8 in the int istruction; anyway, because it is a imm8 a fasm change could inhibit users thinking negative (int -3 instead of int 0FDh) to avoid undesiderable results. in fact in this way, they could only use absolute imm8 values. - retn -4 no fasm change, it is user responsability avoid errors - enter 4,-128 no fasm change,it is not necessary, also, my opinion, if useful is for those instructions no change |
|||
21 Jan 2010, 08:23 |
|
Borsuc 21 Jan 2010, 16:56
revolution wrote: Madis731: "SUB eax,ebx", How to do with ADD? _________________ Previously known as The_Grey_Beast |
|||
21 Jan 2010, 16:56 |
|
revolution 21 Jan 2010, 17:00
Borsuc wrote: I think he was talking about SUB with an immediate. That is worthless and wastes encoding space. |
|||
21 Jan 2010, 17:00 |
|
Madis731 21 Jan 2010, 22:25
@revolution - yes
and @Borsuc - yes and no I'm sorry, but I didn't think about immediates - though I should have - I thought in general SUB is a waste of encoding space, but... well seb eax,ebx is great to have. What I was actually trying to prove that sometimes add eax,-1 is more obfuscated than sub eax,1. I cannot prove, however, that ret or int will have uses in some code. Therefore I shall argue no more |
|||
21 Jan 2010, 22:25 |
|
Borsuc 22 Jan 2010, 17:51
Which flags? The carry flag?
|
|||
22 Jan 2010, 17:51 |
|
revolution 22 Jan 2010, 17:56
Borsuc wrote: Which flags? The carry flag? |
|||
22 Jan 2010, 17:56 |
|
baldr 22 Jan 2010, 20:41
Overflow flag will be different only when (for 32-bit operands) 0x80000000 is added/subtracted (because -0x80000000==0x80000000 ). And don't forget an AF (albeit nobody cares about it).
|
|||
22 Jan 2010, 20:41 |
|
revolution 23 Jan 2010, 02:57
Overflow flag will be different for other values also.
0x80000000 + 0xffffffff ---> carry, no overflow 0x80000000 - 0x00000001 ---> overflow, no carry |
|||
23 Jan 2010, 02:57 |
|
baldr 23 Jan 2010, 04:02
revolution,
0x80000000+0xFFFFFFFF… No overflow, really? -2**31+(-1)==-(2**31+1), which does not fit in signed 32-bit. |
|||
23 Jan 2010, 04:02 |
|
LocoDelAssembly 23 Jan 2010, 04:14
Yep, this crash:
Code: format pe gui 4.0 mov eax, 0x80000000 add eax, 0xffffffff into ret ; I don't care if someone visit this thread in 2020 |
|||
23 Jan 2010, 04:14 |
|
revolution 23 Jan 2010, 04:33
forget about my overflow example.
|
|||
23 Jan 2010, 04:33 |
|
hopcode 25 Jan 2010, 13:11
mmh... i dont know if i mistake but
it seems to me as we are playing in a Buñuel movie (one of my preferite directors with Tarkowskij and Fassbinder), exactly "El ángel exterminador" http://en.wikipedia.org/wiki/The_Exterminating_Angel_%28film%29 by the fact that we discuss round and round on fasm at a "bourgeois" level without safe exiting, neglecting (one of) the most important concepts of fasm, it is to say, the 10 or more years of sssO experience of fasm, in few words, the WYSIWYG feature, that makes fasm so different from other fuzzy-funky-thingy-kopflos-zusamenfassungen compilers. For that feature, one learn in less time (this is what happens to me) and outputs automatically aware less "tricks" as compared to other compilers output. Why obfuscate that capability ? Cheers, hopcode (is that provoking ?) |
|||
25 Jan 2010, 13:11 |
|
bitRAKE 26 Jan 2010, 05:56
If the processor operates with an unsigned number then negative numbers are incorrect. Since FASM correctly errors in some cases and has the precision to detect a number out of bounds, I assume the implementation is just incomplete rather than having this behavior as a feature. Hiding coding errors is never desirable.
|
|||
26 Jan 2010, 05:56 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.