Which is the difference between ADDR and OFFSET? Thanks Saigam
Posted on 2001-05-01 17:08:00 by Saigam
i pulled this from iczelions tutorial #2 The addr operator is used to pass the address of a label to the function. It's valid only in the context of invoke directive. You can't use it to assign the address of a label to a register/variable, for example. You can use offset instead of addr in the above example. However, there are some differences between the two: addr cannot handle forward reference while offset can. For example, if the label is defined somewhere further in the source code than the invoke line, addr will not work. invoke MessageBox,NULL, addr MsgBoxText,addr MsgBoxCaption,MB_OK ...... MsgBoxCaption db "Iczelion Tutorial No.2",0 MsgBoxText db "Win32 Assembly is Great!",0 MASM will report error. If you use offset instead of addr in the above code snippet, MASM will assemble it happily. addr can handle local variables while offset cannot. A local variable is only some reserved space in the stack. You will only know its address during runtime. offset is interpreted during assembly time by the assembler. So it's natural that offset won't work for local variables. addr is able to handle local variables because of the fact that the assembler checks first whether the variable referred to by addr is a global or local one. If it's a global variable, it puts the address of that variable into the object file. In this regard, it works like offset. If it's a local variable, it generates an instruction sequence like this before it actually calls the function: lea eax, LocalVar push eax Since lea can determine the address of a label at runtime, this works fine. smurf
Posted on 2001-05-01 17:18:00 by smurf
ADDR can handle forward references quite acceptably. Well, it always has for me. Generally, masm is a N pass assembler (takes as many passes at it needs). It only balks at a few things it should get if it was truly N pass.
Posted on 2001-05-02 00:28:00 by Ernie
Thanks for smurf and Ernie! Now I know wath addr and offset make... And more two questions: Wath is the maximun size of the AVATAR? This is for I can draw my own AVATAR... :) Because when I type it: .data? Test db 1000000 dup (?) the assembler takes MANY TIME for compile??? Thanks Saigam This message was edited by Saigam, on 5/2/2001 11:21:10 AM
Posted on 2001-05-02 11:19:00 by Saigam
i don't know what do you mean by avatar, but looking at your code i can tell you you'd be better off using dynamically allocating memory for these amounts of undeclared data. you can use any of the allocation functions (GlobalAlloc,VirtualAlloc,HeapAlloc) depending on your needs, and i'm certain it'll make the assembling time much shorter.
Posted on 2001-05-02 16:56:00 by fresh
I am using these functions for alloc memory... And about AVATAR I want know the maximun WIDHT, HEIGHT and the SIZE of the file for I can upload my AVATAR, for example you use "Homer Simpson" photo... Saigam
Posted on 2001-05-02 21:48:00 by Saigam
I've designed my own Avatar using Photoshop 3. The only limitation that I know of is that the image that you create must have a Width <= 102 pixels.
Posted on 2001-05-02 23:09:00 by eeprom
Right clicking on ol' Ernie reveals he is approximately 96 pixels wide, and 119 pixels high.. :D I think thats a good size... NaN
Posted on 2001-05-02 23:12:00 by NaN
Thanks! I will start the drawing of my AVATAR!!! :) Saigam
Posted on 2001-05-03 10:33:00 by Saigam
try uploading a really big avatar. hiroshimator designed it so that if you upload too big of a avatar you will get an error saying its too big and then it will display the maximum height or width depending on what part of the avatar is too big. smurf
Posted on 2001-05-03 14:57:00 by smurf
Good Idea. Saigam
Posted on 2001-05-03 15:29:00 by Saigam