Hello,

I have put together some code to measure some text for a listbox, but the compiler remains giving me the error:

Assembling: listbox.asm
listbox.asm(262) : error A2133: register value overwritten by INVOKE


The line 262 in my code and some previoous coding are as follows:



;this return strlen in eax...

[color=blue]invoke lstrlen,addr lItem4[/color]

;[color=red]push eax[/color] ;this I tried to use to see if error disappeared

;the calll DrawText with it (line 262)
;i broke the line to insert comments here

[color=blue]invoke DrawText,hDC\[/color] ;valid handle ok
[color=blue],addr lItem4\[/color] ;the string ok
[color=blue],eax\[/color] ;possibly the lenght of that string
[color=blue],addr rcText\[/color] ;contain rectangle structure to be filled by DrawText
[color=blue], DT_CALCRECT[/color] ; tell DT what we wanna do...

;[color=red]pop eax[/color] ; ... no use



So what is this error about? Will I have no other option that put EAX in a variable and then pass this one to Drawtext? :(
Posted on 2002-12-18 09:44:29 by wicr0s0ft
it tells you that a register you provided for the function will be overridden by invoke possibly before it had a chance to use it. So use another one :grin:
Posted on 2002-12-18 09:50:08 by Hiroshimator


invoke DrawText,hDC\
,addr lItem4\
,eax\
,addr rcText\
, DT_CALCRECT


Expands to



push DT_CALCRECT
lea eax, rcText
push eax
push eax
lea eax,lItem4
push eax
call DrawText


Therefore the compiler generate an error.
Listen to Hiro, use another register for the length of string
Posted on 2002-12-18 10:26:23 by roticv
Thanks!!

I didn't know how invoke is expanded too... is always that way? If I want to change it I will have to write it manually, right? Doing all necessary pushes... (what a hard work.. ; )

Ok, why does it use LEA instead of MOV? What is the effective difference?

See ya! :)
Posted on 2002-12-18 11:34:20 by wicr0s0ft
ADDR gets translated to lea eax, xXx -> push eax...
For a straight push you need to specify OFFSET
Posted on 2002-12-18 11:47:06 by JimmyClif
Except that an OFFSET of a LOCAL, if it's allowed by MASM, will not be its true address (it leaves out the EBP component.)
Posted on 2002-12-18 14:58:41 by tenkey
Mmm... I have heard somewhere that we cant use 'addr' referring one label wich is after the call we use it. Why is this then? :\
Posted on 2002-12-18 15:05:42 by wicr0s0ft
It is the ADDR that expands to lea eax,blah blah push eax. Use ADDR for both local and global variable, while use only OFFSET for global variables.
Posted on 2002-12-18 22:21:23 by roticv