flat assembler
Message board for the users of flat assembler.
Index
> Windows > sar vs shr |
Author |
|
AsmGuru62 02 Jul 2015, 17:59
Where is # of bits to shift?
Should it be: Code: sar dword [ebp-48], #ofbits |
|||
02 Jul 2015, 17:59 |
|
cod3b453 02 Jul 2015, 23:25
AsmGuru62 wrote: Where is # of bits to shift? Code: sar dword [ebp-48],1 |
|||
02 Jul 2015, 23:25 |
|
sunnysigil 21 Aug 2015, 11:20
yq8 wrote: Yo, sar and shr are not the same instruction since shr only shifts in 0s. sar is used when dealing with signed numbers as it will shift from the right side in 1's if negative or 0's if it's positive. |
|||
21 Aug 2015, 11:20 |
|
shutdownall 21 Aug 2015, 17:32
There are differences between "shift logical right" (shr) and "shift arithmetical right" (sar). See manual.
|
|||
21 Aug 2015, 17:32 |
|
catafest 27 Aug 2015, 20:20
The sar instruction shifts all the bits in the destination operand to the right one bit.
I think you need to know that: sar ax, 1 ;Signed division by 2 sar ax, 2 ;Signed division by 4 sar ax, 3 ;Signed division by 8 sar ax, 4 ;Signed division by 16 sar ax, 5 ;Signed division by 32 sar ax, 6 ;Signed division by 64 sar ax, 7 ;Signed division by 128 sar ax, 8 ;Signed division by 256 - sar truncates results toward the smaller result and idiv instruction always truncates towards zero! - sar instruction lets you sign extend one register into another register of the same size, see this example: mov cx, bx sar cx, 15 I think your answer is this: sar eax,10h mov dword ptr [ebp-8],eax tell me if I wrong ... |
|||
27 Aug 2015, 20:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.