Hello, all...I'm fairly new to assembler and MASM, but by no means new to programming.

I just have a simple question about why

invoke TextOut,hdc,0,0,ADDR foo,SIZEOF foo-1

works, but

.data
PosX db 0
PosY db 0
.code
invoke TextOut,hdc,PosX,PosY,ADDR foo,SIZEOF foo-1

doesn't work. (TextOut is expecting ints for these two arguments). Is it something to do with an int being signed, and db or dw not being signed? How do I make an int-compatible variable in MASM?

Thanks!
Posted on 2002-12-01 02:58:55 by frep45
you're wondering?
look at the definition of TextOut in your API:



BOOL TextOut(

HDC hdc, // handle of device context
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCTSTR lpString, // address of string
int cbString // number of characters in string
);

you have as xpos and ypos an integer; but you define a byte (with db - declare byte). so you gotta define a word (same size as an integer) with dw, but a word sould work too (dd)
Posted on 2002-12-01 03:49:45 by hartyl
Yes, one thing to remember is that Masm32 only does type checking by data size. If you look in windows.inc, you'll see a lot of lines like:

UINT typedef DWORD
Posted on 2002-12-01 04:19:11 by Qweerdy
Just to clear up what hartyl said...
an int/uint is a dword and a short is a word
Posted on 2002-12-01 05:57:30 by MArtial_Code
Alright, I had tried word (dw) before, but not dword (dd). The latter is the only one that works. Thanks for your help, I'll hopefully be asking less noobie-ish questions from now on :)
Posted on 2002-12-01 12:41:59 by frep45
We all Posted on 2002-12-01 23:50:58 by scientica
This is nothing but a malicious lie.

(except from Hutch who was born with a built-in assembler)

Back in about 1990 my original trashcan directory was full of stuff so dangerous that it made an ebola virus look like a common cold.

INT 10h programming on poor technical information was a task only for the brave of heart, you had to hit the reset button before you damaged the monitor but you did get som interesting text mode screens on the way. Random characters in random coloured cells blinking.

Used to look really wild at the time. :grin:

Regards,

hutch@movsd.com
Posted on 2002-12-02 00:43:48 by hutch--