The MASM Forum

General => The Campus => Topic started by: jimg on June 13, 2017, 01:47:52 AM

Title: wsprintf word
Post by: jimg on June 13, 2017, 01:47:52 AM
Is this a known bug in masm I've missed all these years?  (Or is it just another thing I've forgotten with age)

When trying to print an integer using wsprintf, the stack pointer gets screwed up.  Works properly in uasm and variants.

.data
xsp  dd 0
x2p  dd 0
bux db 100 dup (0)
fmt db 'wordtest = %u',0
wtst dw 7
smt db 'before=%li, after=%li',0
.code
mov xsp,esp

inv wsprintf,addr bux,addr fmt, wtst

mov x2p,esp
inv wsprintf,addr bux,addr smt,xsp,x2p
inv MessageBox,0,addr bux,0,0
mov esp,xsp  ; fix


Title: Re: wsprintf word
Post by: qWord on June 13, 2017, 02:38:20 AM
yep, it is a well known bug of the INVOKE directive for BYTE- and WORD-sized parameters that had been fixed with later versions  of MASM (7+ IIRC)
Title: Re: wsprintf word
Post by: jimg on June 13, 2017, 11:33:55 AM
Thank you.  Now that you mention it, I remember something from the dark day before jwasm.  For some reason I was focused on wsprintf rather than invoke.