I see that MASM understands "LOW32" as well but how to use it.
I can't manage to declare a constant bigger than DWORD. ::)
.686p
.model flat, stdcall
option casemap :none
Val EQU 12345678h
;Val EQU 112345678h ;Error too big
.code
start:
mov eax, low32 Val
nop
end start
i think EQUates are traditionally limited to the machine width
as i recall, with old versions of MASM (5 and earlier), it had to resolve to a 16-bit integer
mov eax, low32 (Val*12345678h) works.
oh - i suppose you could use TEXTEQU and have it resolve to other sizes :P
or, as in Jochen's example...
MyConst TEXTEQU <low32 (Val*12345678h)>
mov eax,MyConst
masm use internal 64Bit arithmetic for calculations on constants, but it can only emit 32Bit constants.
All right I guess since there is no "high32" anyway it is just a "dead end" command. :bg
Perhaps is has something to do with 64-bit initializers. Even MASM 5.1 would allow statements like:
xxx dq 1234567812345678h
yah - but defining data is different than using EQUates for constants
thing is - there aren't very many (single) 32-bit instructions that allow use of 64-bit constants
the EQUates "mechanism" wasn't really designed with SSE in mind
QuoteAll right I guess since there is no "high32" anyway it is just a "dead end" command. BigGrin
But, there is a HIGH32 (http://msdn.microsoft.com/en-us/library/ms235621%28VS.80%29.aspx) (in later versions).
Well crap, both of these seem totally useless.
Microsoft (R) Macro Assembler Version 10.00.30319.01 07/06/10 13:53:46
...
push high32 400921FB54442D18h ; PI
test27.asm(23) : error A2084:constant value too large
push low32 400921FB54442D18h
test27.asm(24) : error A2084:constant value too large
Clive,
Try
push HIGH32(400921FB54442D18h) ; PI
push LOW32(400921FB54442D18h)
[Edit] Oops, I guess not.
Here are some macros I wrote for the earlier versions of MASM. I thought they worked the same as the ones in MASM 8.0 and later, I guess not.
; ====================================
; MASM 8.0 has a macro with the same name and function built in
LOW32 MACRO Q:REQ
lea edx, Q
mov eax, DWORD PTR [edx]
EXITM <eax>
ENDM
; ====================================
; MASM 8.0 has a macro with the same name and function built in
HIGH32 MACRO Q:REQ
lea edx, Q
mov eax, DWORD PTR [edx+4]
EXITM <eax>
ENDM
I'm trying to figure out what LOW32 and HIGH32 in MASM 8.0 and later are good for.
Quote from: jj2007mov eax, low32 (Val*12345678h) works.
I get
error A2026: constant expected on that one. I'm using ML 10.0.
[Edit] OK, I see what he means, the following works.
mov eax, LOW32(20*12345678h)
Greg,
I'd tried a bunch of combinations, MASM just doesn't like direct input of constants bigger than 32-bits.
Here's what I finally got to work, but I still don't feel Microsoft really understands the point of these functions.
-Clive
Microsoft (R) Macro Assembler Version 10.00.30319.01 07/06/10 15:49:16
test27.asm Page 1 - 1
.686
.MODEL FLAT
= 3.141592653589793238 PI EQU 3.141592653589793238
00000000 .DATA
00000000 40490FDB REAL4 PI
00000004 400921FB54442D18 REAL8 PI
00000000 .CODE
= 54442D18 _PI EQU ((400921FBh SHL 32) + (54442D18h)) ; PI
00000000 _start:
00000000 68 400921FB push high32 _PI
00000005 68 54442D18 push low32 _PI
0000000A C3 ret
end _start
as said, masm internally use 64bit arithmetic. The only way I currently see is to 'calculate' the 64Bit constant from two 32Bit ones:
foo = (0cccccccch SHL 32) OR (0aaaaaaaah)
.radix 16
%echo @CatStr(%(HIGH32 foo),<_>,%(LOW32 foo))
.radix 10
:bg
masm language could definitely be improved in this area.
not accepting constants for qword,real4,real8 arguments is just annoying.
myproc1 proc qw1:qword,r41:real4,r41:real8
ret
myproc1 endp
invoke myproc1,1,2.0,3.0
just for fun:
pushR8 macro r8:req
dq r8
org $-8
db 3 dup(02eh), 68h
org $+4
db 68h
dq r8
org $-4
endm
PI EQU 3.141592653589793238
pushR8 PI
Quote from: drizz on July 06, 2010, 11:17:40 PM
just for fun:
pushR8 macro r8:req
dq r8
org $-8
db 3 dup(02eh), 68h
org $+4
db 68h
dq r8
org $-4
endm
PI EQU 3.141592653589793238
pushR8 PI
See real or BCD number not allowed (http://www.masm32.com/board/index.php?topic=14312.msg114490#msg114490) for a solution that is compatible with invoke :bg