Hi guys I'm new programming in Assembly.
I am trying to create a subroutine that convert a value in a Variable into an string, so in order to accomplish that I need to get the size of the variable first, so can some body tell me how can I do it in FASM?
Let say for example I have this code:

section '.data' data readable writeable

mainhwnd dd 0 ; handle of window
hinstance dd 0 ; handle of module

Eightbits db 1
Sixteenbits dw 2
Fourtyeightbits dp 6
Sixtyfourbits dq 8
Eightybits dt 10.0

How can I find out with code how many bytes are used by the Eightybits varaible?

Thanks for your help!

Alonso
Posted on 2002-09-13 22:34:08 by alonso
That is not possible to do dynamically at runtime without storing additional information - for Eightybits is only an address and it is the programmer that decides what to do with it - the data there can be interpreted in many ways. If this response is lame then I do not understand what you wish to do. ;)
Posted on 2002-09-13 22:51:33 by bitRAKE

That is not possible to do dynamically at runtime without storing additional information - for Eightybits is only an address and it is the programmer that decides what to do with it - the data there can be interpreted in many ways. If this response is lame then I do not understand what you wish to do. ;)


Thanks your reply.

What I am trying to do is a routine that you do not need to be tell what is the size of the variable (it most be detected automaticly), there have to be a way other wise how can you do this:

push ; how does FASM knows that it have to push 1 byte of data into the stack?

Thanks for your help again!!:)
Posted on 2002-09-14 07:39:48 by alonso

push ; how does FASM knows that it have to push 1 byte of data into the stack?
FASM can do this because it has this information at assemble-time, but it is not present at run-time. If you wish to distinguish between types at assemble-time then changes would have to be made to FASM to provide type information and a macro wrote to execute the proper code for each type. There is a way to accomplish it with just macros, but you would have to re-define DB, DW, DD, ... to produce an equate specifying the label's type, and then use that type information in the multi-type macros. Sounds like much overhead. Thus far, I have assumed you wish to do this at run-time, though. :)
Posted on 2002-09-14 09:51:15 by bitRAKE