flat assembler
Message board for the users of flat assembler.
Index
> Main > Need Help With Quick Bounds Check |
Author |
|
LocoDelAssembly 07 Nov 2007, 15:33
Code: PAGE_SIZE = 65536 ; Always 2^n where n can go from 0 to 30 MOD_MASK = -PAGE_SIZE calculate_bounds:; EAX = Address mov edx, PAGE_SIZE-1 and eax, MOD_MASK add edx, eax ret ; EAX = lower limit; EDX = upper limit [edit] Or maybe better Code: calculate_bounds:; EAX = Address and eax, MOD_MASK lea edx, [eax+PAGE_SIZE-1] ret ; EAX = lower limit; EDX = upper limit |
|||
07 Nov 2007, 15:33 |
|
bitRAKE 07 Nov 2007, 18:11
; assuming granularity is a power of two
add eax, granularity-1 and eax, 0-granularity ; EAX is upper bound (beyond page) ; just subtract page size to get lower bound |
|||
07 Nov 2007, 18:11 |
|
Hayden 08 Nov 2007, 08:53
thanks guys, the code i was useing was like this
persudo code... UpperBounds = (address + grans) - (address mod grans) LowerBounds = address - (address mod grans) _________________ New User.. Hayden McKay. |
|||
08 Nov 2007, 08:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.