News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

mASM BYTE

Started by David, November 26, 2009, 06:15:13 PM

Previous topic - Next topic

David

Hi, how is a BYTE done in mASM? I have tried the following, but it does not work:

BYTE sz[2] = {0x00, 0x00};

dedndave

we use DB (define byte) for bytes

Label0  db 0       ;byte - 1 byte
Label1  dw 0       ;word - 2 bytes
Label2  dd 0       ;dword - 4 bytes
Label3  dq 0       ;qword - 8 bytes
Label4  dt 0       ;tbyte - 10 bytes

for reals

Real0   Real4 1.0  ;4 bytes
Real1   Real8 1.0  ;8 bytes
Real2   Real10 1.0 ;10 bytes

David

Quote from: dedndave on November 26, 2009, 06:20:20 PM
we use DB (define byte) for bytes

Label0  db 0       ;byte - 1 byte
Label1  dw 0       ;word - 2 bytes
Label2  dd 0       ;dword - 4 bytes
Label3  dq 0       ;qword - 8 bytes
Label4  dt 0       ;tbyte - 10 bytes

for reals

Real0   Real4 1.0  ;4 bytes
Real1   Real8 1.0  ;8 bytes
Real2   Real10 1.0 ;10 bytes


Ah I see, but how would I define more then 1 byte?

Is it like this?

BYTE Label1[1] = {0x90}; = 1 byte :  Label0 db 0x90
BYTE Label1[2] = {0x90,0x90}; = 2 bytes : Label1 dw 0x90, 0x90
BYTE Label3[3] = {0x90, 0x90, 0x90}; = 3 bytes : ??
BYTE Label1[4] = {0x90, 0x90, 0x90, 0x90}; = 4 bytes : Label3 dd 0x90, 0x90, 0x90, 0x90

?


dedndave


Label0  db 20 dup(0)            ;creates 20 0's
Label1  db 'String',0,20 dup(?) ;creates a string, a 0, and 20 unknowns

oex

Quote from: dedndave on November 26, 2009, 06:34:06 PM

Label0  db 20 dup(0)            ;creates 20 0's
Label1  db 'String',0,20 dup(?) ;creates a string, a 0, and 20 unknowns


Is that effectively allocate 20 unknowns then 0 fill? Could (?) ever be anything other than (0)?
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

RuiLoureiro

Quote from: David on November 26, 2009, 06:15:13 PM
Hi, how is a BYTE done in mASM? I have tried the following, but it does not work:

BYTE sz[2] = {0x00, 0x00};
is
sz     db 2 dup (00h)                  ; 0x00 = 00h      0x90=90h

BYTE Label1[4] = {0x90, 0x90, 0x90, 0x90};
is
Label1   db 4 dup (90h) 
Rui

David

Quote from: RuiLoureiro on November 26, 2009, 06:50:15 PM
Quote from: David on November 26, 2009, 06:15:13 PM
Hi, how is a BYTE done in mASM? I have tried the following, but it does not work:

BYTE sz[2] = {0x00, 0x00};
is
sz     db 2 dup (00h)                  ; 0x00 = 00h      0x90=90h

BYTE Label1[4] = {0x90, 0x90, 0x90, 0x90};
is
Label1   db 4 dup (90h) 
Rui

How about if I want to create a BYTE with not just one value?  Like BYTE Label1[4] = {0x94, 0x19, 0x20, 0x20};


RuiLoureiro

Quote
How about if I want to create a BYTE with not just one value?  Like BYTE Label1[4] = {0x94, 0x19, 0x20, 0x20};
Quote
Label1    db 94h                    or    Label1  db 94h,19h,20h,20h
             db 19h
             db 20h
             db 20h
Label X ...
Rui

David


hutch--

Try this,


LOCAL Buffer[128]:BYTE


128 bytes allocated on the stack with local scope. Note that the content of the allocated stack buffer is undefined, it can be any trash on the stack. If you want it initialised to anything you must do it yourself.

You get the start address with LEA.


    lea eax, Buffer
  ; set it to zero length for zero terminated strings
    mov BYTE PTR [eax], 0
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php