News:

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

a simple definetion question

Started by Eric4ever, April 26, 2006, 03:56:41 AM

Previous topic - Next topic

Eric4ever

how can I define a buffer like this:
buffer[13]={0x32,0xfc,0xec,0xb7,0x5d,0x34,0x9a,0xfa,0xc6,0x5e,0x28,0x46,0x13}

I use the struct

BUF  struct
Off1 byte   ?
Off2  byte   ?
Off3  byte   ?
Off4  byte   ?
Off5  byte   ?
Off6  byte   ?
Off7  byte   ?
Off8  byte   ?
Off9  byte   ?
OffA  byte   ?
OffB  byte   ?
OffC  byte   ?
BUF  ends

stBuf   BUF   <0x32,0xfc,0xec,0xb7,0x5d,0x34,0x9a,0xfa,0xc6,0x5e,0x28,0x46,0x13>
OR
stBuf   BUF   <32h,fch,ech,b7h,5dh,34h,9ah,fah,c6h,5eh,28h,46h,13h>

There's something wrong. And so does the one below:

szBuffer  db  13  dup  (32h,fch,ech,b7h,5dh,34h,9ah,fah,c6h,5eh,28h,46h,13h)

hutch--

eric,

Try this,


    eric STRUCT
      b1 byte ?
      b2 byte ?
      b3 byte ?
      b4 byte ?
      b5 byte ?
      b6 byte ?
      b7 byte ?
      b8 byte ?
      b9 byte ?
      ba byte ?
      bb byte ?
      bc byte ?
      bd byte ?
      be byte ?
      bf byte ?
      b0 byte ?
    eric ENDS

    .data
      items eric 16 dup (<1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6>)
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Quote from: Eric4ever on April 26, 2006, 03:56:41 AM
szBuffer  db  13  dup  (32h,fch,ech,b7h,5dh,34h,9ah,fah,c6h,5eh,28h,46h,13h)

Hi Eric, note you must prefix each "fch,ech,b7h" etc... with a zero, else MASM will not treat them as hex values. Try "0fch,0ech,0b7h", etc. All immediate (integer) values must start with a number, even if it is a zero. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

GregL

unsigned char buffer[13] = {0x32,0xfc,0xec,0xb7,0x5d,0x34,0x9a,0xfa,0xc6,0x5e,0x28,0x46,0x13};
equals
buffer BYTE 32h,0fch,0ech,0b7h,5dh,34h,9ah,0fah,0c6h,5eh,28h,46h,13h

Eric4ever

Thank you all :U

add zero in front of the hexnumber is a simple and effective method. :clap:

BTW, hutch,

could you tell me something more about "items eric 16 dup (<1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6>)".
or where can I find some instructions? THX in advance.

hutch--

eric,

A structure requires the <>, with or without content like the comma seperate list where the DUP operator requires () around what it duplicates.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PBrennick

That is pretty fancy stuff, Hutch, never thought of doing it that way. Pretty simple once you see it, though.

Paul
The GeneSys Project is available from:
The Repository or My crappy website