flat assembler
Message board for the users of flat assembler.
Index
> Main > no jump Goto page Previous 1, 2 |
Author |
|
r22 08 May 2009, 20:17
Speed-wise I think CMOV would be the fastest method.
Here's my 9 byte variation Code: SETZ al SETNZ ah ADD ax,0AFFh |
|||
08 May 2009, 20:17 |
|
bitshifter 09 May 2009, 05:29
Yeah right, wheres the CMOV?
|
|||
09 May 2009, 05:29 |
|
Mac2004 09 May 2009, 06:56
bitshifter wrote: It's cool to see so many people getting involved It seems like many board members wish to share "the fun of optimization" regards, Mac2004 |
|||
09 May 2009, 06:56 |
|
bitRAKE 09 May 2009, 15:58
I had thought about using LAHF and grabbing the ZF bit directly, but can't manage a smaller version. If we allow a massive data table it becomes easy to produce smaller variants, but that ignores the size of the data.
|
|||
09 May 2009, 15:58 |
|
r22 11 May 2009, 16:19
revolution wrote:
Can you clearify ... It seems to work for me ... Test Code: format PE CONSOLE include 'win32ax.inc' cinvoke printf,<'Start',13,10,0> xor eax,eax test eax,eax; zf=1 jnz .exit ;ut-oh? setz al setnz ah add ax,0AFFh cinvoke printf,<'ZF = 1 THEN AX = %X ',13,10,0>,eax mov eax,1 test eax,eax; zf=0 jz .exit ;ut-oh? setz al setnz ah add ax,0AFFh cinvoke printf,<'ZF = 0 THEN AX = %X ',13,10,0>,eax .exit: invoke system,"pause" invoke ExitProcess,0 data import library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ msvcrt,'MSVCRT.DLL' import kernel32,\ ExitProcess,'ExitProcess' import user32,\ MessageBoxA,'MessageBoxA' import msvcrt,\ printf,'printf',\ system,'system' end data Output Code: Start ZF = 1 THEN AX = B00 ZF = 0 THEN AX = BFF Press any key to continue . . . |
|||
11 May 2009, 16:19 |
|
revolution 11 May 2009, 19:45
It only works because you have "mov eax,1" in there pre-initialising the value of AX. Cheater!
[edit]My mistake, as above.[/edit] Last edited by revolution on 11 May 2009, 21:53; edited 1 time in total |
|||
11 May 2009, 19:45 |
|
LocoDelAssembly 11 May 2009, 21:30
Come on revolution, you'll confuse some people. (I even believed you when you said it won't work...)
r22's code works because of the following: Code: SETZ al ; IF ZF THEN AL = 1; else AL = 0 SETNZ ah ; IF ZF THEN AH = 0; else AH = 1 ADD ax,0AFFh ; AX = $BFF WHEN AL = 0 and AH = 1 ; i.e. lower part of $0AFF intact, higher part incremented ; AX = $B00 WHEN AL = 1 and AH = 0 ; i.e. lower part of $0AFF incremented and wrapped around to zero, higher part incremented because of the carry from the lower part. |
|||
11 May 2009, 21:30 |
|
revolution 11 May 2009, 21:39
It only works if AX has some known value before execution. If I have the following what happens:
Code: mov eax,0x12345678 cmp ebx,ecx SETZ al SETNZ ah ADD ax,0AFFh [edit]Please ignore, what I said is not true.[/edit] Last edited by revolution on 11 May 2009, 21:54; edited 1 time in total |
|||
11 May 2009, 21:39 |
|
LocoDelAssembly 11 May 2009, 21:41
AX will be either $0B00 or $0BFF. And before AX is set with those values it was either $0001 or $0100.
|
|||
11 May 2009, 21:41 |
|
revolution 11 May 2009, 21:45
LocoDelAssembly wrote: AX will be either $0B00 or $0BFF. And before AX is set with those values it was either $0001 or $0100. |
|||
11 May 2009, 21:45 |
|
MazeGen 12 May 2009, 09:17
The confusion is caused by source code obfuscation perhaps. I hope nobody writes real source code like this
Code: SETZ al SETNZ ah ADD ax,0AFFh |
|||
12 May 2009, 09:17 |
|
r22 12 May 2009, 12:43
12 posts for 3 lines of ASM I think we've reached a new exciting level ... of insanity
@LocoDel - Rev had me convinced as well, and I wrote the original snippet ! I had to compile an example just to prove myself right ... to myself @MazeGen - I should of put SETNZ AH as the first instruction instead of the confusing SETZ AL |
|||
12 May 2009, 12:43 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.