Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add consistent access to struct members also on local vars #218

Open
LowLevelMahn opened this issue Oct 20, 2024 · 3 comments
Open

Comments

@LowLevelMahn
Copy link

tested with UASM 2.57

struct member addressing on global vars is different to local proc vars - with globals i can left out the struct on accessing
is there a reason for not allowing this address schema also on local variables?

the example is only assemble-able it does not produce an working program

my_struct struc
  one dw ?
  two dw ?
my_struct ends

.MODEL small
.STACK 100h
.DATA
  global_var my_struct<0>	

.CODE

local_var_test proc near
  local_var = my_struct ptr 4

  mov ax,[bp+local_var+my_struct.two] ; OK
  ;mov ax,[bp+local_var.two] ; ERROR: Error A2274: structure field expected <=======

local_var_test endp

start:
  mov ax,[global_var+my_struct.two] ; OK
  mov ax,[global_var.two] ; OK with global <=======
  
end start

i found that while reversing a DOS game using IDA Pro
the assembler output of IDA is nearly out of the box re-assemble-able with UASM (much better compared to MASM or WASM)
but this struct var access schema difference makes it a little harder to work out of the box

@mrfearless
Copy link

mrfearless commented Oct 20, 2024

try:
mov ax, word ptr local_var.two
or
mov ax, local_var.two
or if you need bp to reference then:
mov ax, word ptr [bp].local_var.two

@LowLevelMahn
Copy link
Author

LowLevelMahn commented Oct 20, 2024

@mrfearless

mov ax, word ptr local_var.two
mov ax, local_var.two
mov ax, word ptr [bp].local_var.two

all fail with the same: Error A2274: structure field expected

IDA Pro (still gold standard in reversing tools)
produces this form mov ax,[(e)bp+local_var.two] (for 16/32 bit code) and UASM support it this way on globals
so i (just) hoped that can be fixed because i can't see any reason for not supporting that access schema also for locals

so allowing that with UASM would make UASM another step better then MASM/WASM for re-assembling IDA output (its already nearly the best for IDA reassembling)

@LowLevelMahn
Copy link
Author

LowLevelMahn commented Nov 2, 2024

had an dicussion on https://masm32.com/board/index.php?topic=12351.msg134318#msg134318 with a good explanation from _japheth why having that feature could break compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants