News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

division

Started by A_B, February 15, 2010, 02:03:55 AM

Previous topic - Next topic

jj2007

Quote from: dedndave on February 16, 2010, 06:30:52 PM
maybe the way to go is to fix it with a macro
we need some macro guy to come up with CodeAlign  (cough - JJ - cough)   :P

Cute idea, if only the Masm documentation was not so hopelessly cryptic. The problem is, you need an assembly time integer checking what the current alignment is. Getting EIP into a register is easy: mov eax, THIS NEAR - but this is not what we want.
I have been fumbling with LABEL NEAR, $, LROFFSET but no success... maybe you have an idea?

qWord

code alignment isn't hard to do using the location counter '$'.There are only two problems:
- code alignment may lost in non-main-modules (e.g. libs) through section combine
- only works in release mode

macro-code attached

qWord

FPU in a trice: SmplMath
It's that simple!

dedndave

i knew it was problematic
in older versions of masm, like 5.10, you couldn't do any math with an offset value   :P
the best solution is to patch the assembler, but that isn't going to be easy
what i did on ling long kai fang was place NOP's in a non-executed place  and adjust until the loop was aligned - not a very clean method

but, i think qWord is on to something
if you combine his macro with the assemblers ALIGN, you might have something that works in all cases
for example:
a secondary routine in a library is one place where he says it won't work
but, if you use a non-executed ALIGN directive at the beginning of that routine,
you might be able to make the macro method work because it has a known reference point - i dunno