flat assembler
Message board for the users of flat assembler.
Index
> Main > add by sub vs sub by add |
Author |
|
bitRAKE 17 Aug 2024, 04:59
With regard to size:
Code: add eax, -0x80 ; 83 C0 80 sub eax, 0x80 ; 2D 80 00 00 00 Performatively, they use the same execution units. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
17 Aug 2024, 04:59 |
|
Ali.Z 17 Aug 2024, 05:49
bitRAKE wrote: With regard to size thanks i missed this one, an important note to consider for size optimizations _________________ Asm For Wise Humans |
|||
17 Aug 2024, 05:49 |
|
revolution 17 Aug 2024, 08:13
The carry flag will be inverted if the second argument is not zero.
The other flags are the same. So if you need to use cmc after add/sub, then you can instead use sub/add and omit the cmc. |
|||
17 Aug 2024, 08:13 |
|
Ali.Z 17 Aug 2024, 17:16
that implies carry and borrow if i understand correctly.
_________________ Asm For Wise Humans |
|||
17 Aug 2024, 17:16 |
|
bitRAKE 29 Aug 2024, 06:08
revolution wrote: So if you need to use cmc after add/sub, then you can instead use sub/add and omit the cmc. The DIV instruction quotient rounds to zero. Sometimes we want to round to infinity. One way to do that is to adjust the input number: Code: mov rcx, [.divisor] lea rbx, [rcx-1] add rax, rbx adc rdx, 0 div rcx Code: div [.divisor] cmp rdx, 1 ; sub rdx, 1 cmc adc rax, 0 Code: div [.divisor] add rdx, -1 adc rax, 0 _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
29 Aug 2024, 06:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.