Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
221 stars 49 forks source link

Referencing code label in memory address messes up size #127

Closed vid512 closed 3 years ago

vid512 commented 4 years ago

It seems that referencing code label in memory address messes up the associated size of entire addressing expression, even though the entire expression size is explicitly specified with dword ptr. Curious thing is that type(...) operator still seems to return correct type, but size(type(...)) doesn't return correct size for that type. Another curious thing is that this doesn't happen when memory addressing references data label, only with code label. I'm new to this highlevel MASM stuff, so maybe I am missing something, but it seems like a bug to me.

Example: following code throws only "error 6", not others. Tested with UASM 2.47 and 2.49.

.code
the_label:
the_byte db 0
if      type( dword ptr [rax] )  NE type(dword)
 "error 1"
endif
if size(type( dword ptr [rax] )) NE 4
 "error 2"
endif
if      type( dword ptr [the_byte] )  NE type(dword)
 "error 3"
endif
if size(type( dword ptr [the_byte] )) NE 4
 "error 4"
endif
if      type( dword ptr [the_label] )  NE type(dword)
 "error 5"
endif
if size(type( dword ptr [the_label] )) NE 4
 "error 6"
endif
end
VitorEAFeliciano commented 4 years ago

Yes this is true, but some time normal behavior.

In data the pointer can exist has reference so the real type size always be the same.

In code for 64bits/32bits platform all type pointer is: 8/64bits. 4/32bits. no maters it's ptr or array, the size is always the same.