News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Echo value of offset

Started by Rockphorr, June 09, 2024, 04:51:25 AM

Previous topic - Next topic

Rockphorr

How to do it ?

See the code and results in attachment.

Regards, Rockphorr.

NoCforMe

I believe you may have invoked the Macro Master's name.
JJ should be along shortly.
Assembly language programming should be fun. That's why I do it.

HSE

There is no variable declaration, then offset will not work (like error say).

For example:
.data
      Mysome Some {0,0,0,0}
Equations in Assembly: SmplMath

Rockphorr

Quote from: HSE on June 09, 2024, 05:50:51 AMThere is no variable declaration, then offset will not work (like error say).

For example:
.data
      Mysome Some {0,0,0,0}


Post complete working code please. May be it is impossible to write code doing this.

jj2007

What's the problem? It seems to work:
*** Assemble, link and run VALUE_ASM ***

*** Assemble using UAsm64  ***
@V_size    =    8h
@V_ofs    =    4h
Tmp_File.asm(31) : Error A2099: END directive required at end of file

Quote from: Rockphorr on June 09, 2024, 06:15:17 AMPost complete working code please.

Normally, I agree. But here OP just wants the echos - and they work.

The CodeSize macro works in a similar fashion.

HSE

Quote from: Rockphorr on June 09, 2024, 06:15:17 AMPost complete working code please. May be it is impossible to write code doing this.

:biggrin: Just paste that 2 lines before .code
Equations in Assembly: SmplMath

Rockphorr

;=======[ STRUCTURE ]===============
Some\
STRUC
Some_Data_0\
BYTE ?
Some_Data_1\
BYTE ?
Some_Data_2\
WORD ?
Some_Method\
DWORD ?
Some\
ENDS


;======[ MACRO ]====================
@Value MACRO name:req, expression:req
 .RADIX 10h
 %ECHO @CatStr (<name>,< = >,%expression,<h>)
 .RADIX 0Ah
  ENDM

.386
.MODEL FLAT


.DATA
      Mysome Some {0,0,0,0}


.CODE


@Value @V_size,Size(Some)

@Value @V_ofs,OFFSET( (Some PTR[0]).Some_Method )



results:

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.
 Assembling: value.asm
@V_size =       8h
value.asm(37) : error A2027: operand must be a memory expression
 @CatStr(1): Macro Called From
  @Value(2): Macro Called From
   value.asm(37): Main Line Code
@V_ofs  =       0h
value.asm(37) : error A2088: END directive required at end of file

Rockphorr

Quote from: jj2007 on June 09, 2024, 06:18:49 AM*** Assemble, link and run VALUE_ASM ***

*** Assemble using UAsm64  ***

Quote from: Rockphorr on June 09, 2024, 06:15:17 AMPost complete working code please.

Normally, I agree. But here OP just wants the echos - and they work.

The CodeSize macro works in a similar fashion.

I use ml of masm32 from masm32.com instead your UAsm64

HSE

 :biggrin: it's a lot more simple that your idea:
;=======[ STRUCTURE ]===============
Some\
STRUC
Some_Data_0\
BYTE ?
Some_Data_1\
BYTE ?
Some_Data_2\
WORD ?
Some_Method\
DWORD ?
Some\
ENDS


;======[ MACRO ]====================
@Value MACRO name:req, expression:req
 .RADIX 10h
 %ECHO @CatStr (<name>,< = >,%expression,<h>)
 .RADIX 0Ah
  ENDM

.386
.MODEL FLAT

.code

@Value @V_size,Size(Some)
@Value @V_ofs,Some.Some_Method

end
Equations in Assembly: SmplMath

Rockphorr

Quote from: HSE on June 09, 2024, 07:43:26 AM:biggrin: it's a lot more simple that your idea:
;=======[ STRUCTURE ]===============
Some\
STRUC
Some_Data_0\
BYTE ?
Some_Data_1\
BYTE ?
Some_Data_2\
WORD ?
Some_Method\
DWORD ?
Some\
ENDS


;======[ MACRO ]====================
@Value MACRO name:req, expression:req
 .RADIX 10h
 %ECHO @CatStr (<name>,< = >,%expression,<h>)
 .RADIX 0Ah
  ENDM

.386
.MODEL FLAT

.code

@Value @V_size,Size(Some)
@Value @V_ofs,Some.Some_Method

end

ups, it was my fault,
Your code works fine!
Thanx!!!

NoCforMe

Strange; I got it to assemble OK (but not link):
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: value.asm
@V_size =       8h
@V_ofs  =       4h
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
value.exe : fatal error LNK1120: 1 unresolved externals
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: Rockphorr on June 09, 2024, 07:36:56 AMI use ml of masm32 from masm32.com instead your UAsm64

UAsm is a Masm32 clone, 100% compatible. And at least a factor 3 faster.

Rockphorr

Quote from: NoCforMe on June 09, 2024, 07:59:15 AMStrange; I got it to assemble OK (but not link):
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: value.asm
@V_size =       8h
@V_ofs  =       4h
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
value.exe : fatal error LNK1120: 1 unresolved externals


Couse this obj has no code inside. Link did not find any label of code.

NoCforMe

Yes, exactly.
I didn't mean to bring this up to further muddy the waters.
So did you get everything to work OK?
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on June 09, 2024, 09:05:35 AMSo did you get everything to work OK?
Maybe I am a little slow, but I don't understand what this piece of code is actually supposed to do...  :undecided:
As is, it seems not very useful as a program since the object file has no code. Am I missing some key point to this?

Maybe it would be more useful to show an example of how/where it would be used.
"We are living in interesting times"   :tongue: