News:

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

Main Menu

retrieve a qword's address in a macro

Started by gelatine1, October 24, 2015, 07:24:35 AM

Previous topic - Next topic

gelatine1

Another macro question... So I created some working code working with real4 (see previous macro posts fom me..) and now I also wanted to created a similar macro for real8. I now have this :


procR8 MACRO prc:REQ,args:VARARG
LOCAL item,txt,temp
txt TEXTEQU <prc>
FOR item, <args>
IF ISFLOAT?(item) ;name says it all.
temp EQU offset <FLT8(item)>
% echo temp
txt CATSTR txt,<,> , <[%temp]> ,<,>, <[%temp+4]> ;Something wrong here
ELSE
txt CATSTR txt,<,> , <item>
ENDIF
    ENDM
%echo <txt>
invoke txt
ENDM



below is the FLT8 macro but it's not so important to read this (just in case..)



gfl_glb_cntr8 = 0
FLT8 MACRO lit:REQ  ;Thanks to qword!
LOCAL lbl

grc_const_found8 = 0
grc_cntr8 = 0
WHILE grc_cntr8 LT gfl_glb_cntr8
% IFIDN <&lit>,<@CatStr(<const_flt8__>,%grc_cntr8)>
grc_const_found8 = -1
EXITM
ENDIF
grc_cntr8 = grc_cntr8 + 1
ENDM
IF grc_const_found8 EQ 0
.const
lbl REAl8 lit
.code
@CatStr(<const_flt8__>,%gfl_glb_cntr8) TEXTEQU <&lit>
@CatStr(<const_flt8_lbl__>,%gfl_glb_cntr8) TEXTEQU <lbl>
gfl_glb_cntr8 = gfl_glb_cntr8 + 1
EXITM <lbl>
ELSE
EXITM @CatStr(<const_flt8_lbl__>,%grc_cntr8)
ENDIF
ENDM


So in the procR8 macro I would like to push the QWord / real8 value onto the stack. Because I read that it is not possible to push 64 bits directly onto the stack I decided to get the address of the real8 value and then use addres,address+4 in the invoke at the end. But clearly the code I have is not getting/using that address in the right way. What would be the correct way to do this ?

thanks in advance (once again..)

qWord

Quote from: gelatine1 on October 24, 2015, 07:24:35 AMtemp EQU offset <FLT8(item)>
RTFM

temp TEXTEQU FLT8(item)
...
push temp[4]
push temp[0]
MREAL macros - when you need floating point arithmetic while assembling!

gelatine1

Quote from: qWord on October 26, 2015, 01:25:17 AM
RTFM

Thanks, What manual do you suggest ? the following code was what did the trick


temp TEXTEQU FLT8(item)
...
push dword ptr temp[4]
push dword ptr temp[0]

dedndave

he's probably refering to the masm programmers ref manual
which isn't particularly well written in my opinion, but, the info is there if you read it enough times

qWord

The user Shosen from the old board did create PDFs from the original Word Documents. I did upload the zip file again: MASM_6.1_Manuals_[High_Quality_PDF]

To learn macro writing, first read Chapter 9 in the Programmer's guide.
If syntax questions come up, also take a look in the MASM Reference (Reference.pdf).
MREAL macros - when you need floating point arithmetic while assembling!

GoneFishing

@Qword:
   Do you have MASM_6.1_Manual_Artworks_[EPS_Format].zip archive that Shosen was refering to in that thread?