Hi all!
Some macros to print xmm contents (registers or variables).
In 32 bits tested with UASM32, AsmC (with /Znk option) and ML.
In 64 bits tested with MASM64 SDK and ml64 v14 (required some additional pointers typecasts). Take me some extra hours because invoke macro was not full suited for the job and... in 64 bits calling print function erase xmm registers!!! :eusa_snooty:
i8x$(xmm6) = 1 -2 3 4 -5 6 7 8 9 10 -11 12 13 14 15 16
u8x$(xmm6) = 1 254 3 4 251 6 7 8 9 10 245 12 13 14 15 16
i16x$(xmm1) = 1 2 3 4 -5 6 7 8
u16x$(xmm1) = 1 2 3 4 65531 6 7 8
i32x$(xmm0) = -1 2 3 4
u32x$(xmm0) = 4294967295 2 3 4
i64x$(xmm4) = 17 -200
u64x$(xmm4) = 17 18446744073709551416
real4x$(xmm5) = 1.30 2.70 3.10 4.50
real8x$(oword1) = -5.8000 125.4000
Press any key to continue...
Thanks in advance for testing, HSE.
Hi HSE,
i8x$(xmm6) = 1 -2 3 4 -5 6 7 8 9 10 -11 12 13 14 15 16
u8x$(xmm6) = 1 254 3 4 251 6 7 8 9 10 245 12 13 14 15 16
i16x$(xmm1) = 1 2 3 4 -5 6 7 8
u16x$(xmm1) = 1 2 3 4 65531 6 7 8
i32x$(xmm0) = -1 2 3 4
u32x$(xmm0) = 4294967295 2 3 4
i64x$(xmm4) = 17 -200
u64x$(xmm4) = 17 18446744073709551416
real4x$(xmm5) = 1.30 2.70 3.10 4.50
real8x$(oword1) = -5.8000 125.4000
Press any key to continue...
Hi,
same result here as in the first post.
Biterider
You can expect the invoke macro to work on 64 bit and smaller data sizes, that is how the Microsoft x64 ABI is designed. When you use larger data types you either pass by register (128 or 256 bit) or you pass by address of the data with 64 bit pointers.
I have no doubt that your macros work, Hector, but why so many different macros? One is enough. Watch the type of variable (http://masm32.com/board/index.php?topic=9280.0) thread :cool:
include \masm32\MasmBasic\MasmBasic.inc
SetGlobals v1:QWORD=1234567890123456789, v2:REAL8=1234567890123456789.0
Init
Print Str$("v1 as int\t%i\n", v1)
Print Str$("v2 as real\t%Jf\n", v2)
movlps xmm0, v1
Print Str$("Xmm0 qword\t%i\n", xmm0)
movlps xmm0, v2
Print Str$("Xmm0 Real8/i\t%i\n", f:xmm0)
Print Str$("Xmm0 Real8/f\t%Jf\n", f:xmm0)
fild v1
Print Str$("ST(0), fild\t%i\n", ST(0)v)
fld v2
Print Str$("ST(0), fld\t%Jf\n", ST(0)v)
mov eax, dword ptr v1
mov edx, dword ptr v1[4]
Inkey Str$("edx::eax\t%i\n", edx::eax)
EndOfCode
Output:
v1 as int 1234567890123456789
v2 as real 1234567890123456768.
Xmm0 qword 1234567890123456789
Xmm0 Real8/i 1234567890123456768
Xmm0 Real8/f 1234567890123456768.
ST(0), fild 1234567890123456789
ST(0), fld 1234567890123456768.
edx::eax 1234567890123456789
Thanks LiaoMi and Biterider!
Quote from: hutch-- on April 04, 2021, 07:29:30 AM
When you use larger data types ...
Ok. It's not the weekend :biggrin:
The problem was that I'm using smaller data types: bytes, words and dwords.
Quote from: jj2007 on April 04, 2021, 07:33:57 AM
Output:
Xmm0 qword 1234567890123456789
Xmm0 Real8/i 1234567890123456768
Xmm0 Real8/f 1234567890123456768.
Another one :biggrin:
What have to do that with the screen I showed and macros to produce that solution?
Thanks, HSE
Quote from: HSE on April 04, 2021, 08:38:21 AMWhat have to do that with the screen I showed and macros to produce that solution?
I'm just pointing you to the fact that you are working with a really powerful MACRO assembler. You can hand over multiple types of arguments to a single NumberToString(arg) macro that accepts reg32, xmmreg, global and local variables, even FPU registers. A sequence of IF TYPE(arg) eq DWORD ... ELSEIF TYPE(arg) eq REAL4 ... etc allows you to choose the right actions under the hood. OPATTR, in contrast, allows you to check if the arg is a register, a local or global variable, etc.
include \masm32\include\masm32rt.inc
.xmm
.data
MyDD dd 123456789
MySD SDWORD 123456789
MyR4 REAL4 123456789.0
MyQ dq 123456789123456789
MySQ SQWORD 123456789123456789
MyR8 REAL8 123456789.0
TellMeTheType macro arg
Local oa
if type(arg) eq DWORD
echo arg is a DWORD
elseif type(arg) eq REAL4
echo arg is a REAL4
elseif type(arg) eq REAL8
echo arg is a REAL8
elseif type(arg) eq QWORD
echo arg is a QWORD
elseif type(arg) eq SQWORD
echo arg is a SQWORD
elseif type(arg) eq SDWORD
echo arg is a SDWORD
else
oa = (opattr arg) AND 127
if oa eq 48
echo arg is a register, but the type is unknown
elseif oa eq 36
echo arg is an immediate
else
echo no idea what arg is, sorry
endif
endif
ENDM
.code
start:
TellMeTheType MyDD
TellMeTheType MySD
TellMeTheType MyR4
TellMeTheType MyQ
TellMeTheType MySQ
TellMeTheType MyR8
echo --------
TellMeTheType eax
TellMeTheType 123
TellMeTheType xmm0
TellMeTheType ST(0)
.err ; we don't need to assemble this, we only want to see the echos
exit
end start
Note that the Masm32 SDK assembler, MASM version 6.14, does not understand SQWORD. Use MASM 8.0 upwards or a modern assembler like UAsm or AsmC.
Quote from: jj2007 on April 04, 2021, 08:47:31 AM
I'm just pointing you to the fact that you are working with a really powerful MACRO assembler. You can hand over multiple types of arguments to a single NumberToString(arg) macro that accepts reg32, xmmreg, global and local variables, even FPU registers. A sequence of IF TYPE(arg) eq DWORD ... ELSEIF TYPE(arg) eq REAL4 ... etc allows you to choose the right actions under the hood. OPATTR, in contrast, allows you to check if the arg is a register, a local or global variable, etc.
I'm not worried. It's just the weekend. :biggrin:
I think only reading (or writing) the program you can know what there are in an xmm register. No TYPEs. OPATTR nothing to do.
Quote from: jj2007 on April 04, 2021, 08:47:31 AM
allows you to choose the right actions under the hood.
That is what you can do just selecting a macro :thumbsup:
Quote from: HSE on April 04, 2021, 09:24:48 AMThat is what you can do just selecting a macro :thumbsup:
Why choose a simple solution if you can have a complicated one, too :tongue:
Hi All!!
Here a 64 bit versiĆ³n more clean, but that relly in invoke macro promoting real4 to real8 (following x64 ABI).
Regards, HSE.