News:

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

Define byte LengthOF

Started by AgentSmithers, June 03, 2009, 07:44:14 AM

Previous topic - Next topic

AgentSmithers

AAAuth  db  "GET / HTTP/1.0",13,10
                            db  "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, "
                            db  "application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*",13,10
                            db  "Content-Type: application/x-www-form-urlencoded",13,10
                            db  "Connection: keep-alive",13,10
                            db  "Host: 192.168.1.1",13,10
                            db  "Authorization: Basic "


When I use LENGTHOF AAAuth it only seems to fetch the length of the First ARRAY how do I make it get the length to the last line?

ecube


AAAuth  db  "GET / HTTP/1.0",13,10
                            db  "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, "
                            db  "application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*",13,10
                            db  "Content-Type: application/x-www-form-urlencoded",13,10
                            db  "Connection: keep-alive",13,10
                            db  "Host: 192.168.1.1",13,10
                            db  "Authorization: Basic ",0

MichaelW

You can use one DB directive and line continuation so the whole thing is one (source) line. There is a line-length limit, but you are ~65 bytes below that.

    .data
      AAAuth db "GET / HTTP/1.0",13,10,\
      "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, ",\
      "application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*",13,10,\
      "Content-Type: application/x-www-form-urlencoded",13,10,\
      "Connection: keep-alive",13,10,\
      "Host: 192.168.1.1",13,10,\
      "Authorization: Basic ",0
    .code

eschew obfuscation


cobold

Just a side note: (maybe you know already)

In your case (AAAuth) is a BYTE array, so it does not matter whether you use LENGTHOF or SIZEOF.
But if you want to know the number of BYTES of an array of any other type, use SIZEOF:
.ie


; LENGTHOF array = number of elements of array
; SIZEOF   array = number of bytes of array
; TYPE     array = number of bytes per element

myArrBYTE   db 100 dup(?)   --->   LENGTHOF = 100, SIZEOF = 100 TYPE = 1
myArrDWORD  dd 100 dup(?)   --->   LENGTHOF = 100, SIZEOF = 400 TYPE = 4
myArrQWORD  dq 100 dup(?)   --->   LENGTHOF = 100, SIZEOF = 800 TYPE = 8


cobold

dedndave

i must be old-fashioned
i do it this way

AAAuth db "GET / HTTP/1.0",13,10
db "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, "
db "application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*",13,10
db "Content-Type: application/x-www-form-urlencoded",13,10
db "Connection: keep-alive",13,10
db "Host: 192.168.1.1",13,10
db "Authorization: Basic "
AAAuthLENGTH EQU $-AAAuth

then use "AAAuthLENGTH" instead of "lengthof AAAuth" or "sizeof AAAuth"
it also annotates the end of the string so if i read the code a year later, i know what it was
another method would be to define the string as a structure, then use "sizeof structurename"

AgentSmithers

Ahh Thanks! All verry nice to know.