flat assembler
Message board for the users of flat assembler.
Index
> Main > Flags Reference/General Assembly Hacks |
Author |
|
moveax41h 20 Jul 2018, 21:57
Hello,
I remember a while ago, I had found either a written work or video which essentially explained a lot of tips and tricks that the flags register and flags-based mnemonics could be used for. Things like, for example: "If after performing an add instruction the CF is set and the OF is not set, then this means X" Or "You can use ADC rather than ADD here" That kind of stuff. I still remember what the flags mean in and of themselves, but I am looking for some guide which provides interpretation, tips, tricks, and hints as to how to effectively use the flags. Also, any other general x86 "hacks" would be appreciated. I have the book Hacker's Delight, and I also found this page which is pretty cool. Thank you. _________________ -moveax41h |
|||
20 Jul 2018, 21:57 |
|
DimonSoft 20 Jul 2018, 22:42
Kind of related stuff: https://board.flatassembler.net/topic.php?t=20547
And there also used to be a topic where a lot of discussion was related to replacing DIV with MUL. |
|||
20 Jul 2018, 22:42 |
|
DimonSoft 21 Jul 2018, 08:42
moveax41h wrote: What do you recommend for figuring out the "higher level" view of what some code is doing... This is C syntax but ofc this could easily be in assembly: I guess, in such cases you either have enough experience to know such a trick and recognize it in spite of small implementation differences or you sit down and carefully step through the operations performing the equivalent of abstract interpretation in your head. Well, in this case you can just take a look at the function identifier How I see this code. Let x is some hex value consisting of 4 bytes, say AABBCCDD (I use these here not as exact values but as some means to mark values of bytes). First line: (x << 8) is BBCCDD00 (x << 8) & 0xFF00FF00 is BB00DD00 (x >> 8) is 00AABBCC (x >> 8) & 0x00FF00FF is 00AA00CC First line results in x = BBAADDCC Second line: (x >> 16) is 0000BBAA (x << 16) is DDCC0000 Second line results in x = DDCCBBAA So, basically it is some kind of cool bit/byte shaking that does what is required. I personally don’t like such tricks since (1) they are tied to fixed operand size in most cases (although can be extrapolated for any size), (2) they may often be implemented more efficiently in ASM than in HLLs and (3) learning them doesn’t pay back ’cause in most cases your task is slightly different but renders the whole trick useless. |
|||
21 Jul 2018, 08:42 |
|
revolution 21 Jul 2018, 10:10
moveax41h wrote: DimonSoft, |
|||
21 Jul 2018, 10:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.