The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: AgentSmithers on June 03, 2009, 07:44:14 AM

Title: Define byte LengthOF
Post by: AgentSmithers on June 03, 2009, 07:44:14 AM
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?
Title: Re: Define byte LengthOF
Post by: ecube on June 03, 2009, 07:50:22 AM

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
Title: Re: Define byte LengthOF
Post by: MichaelW on June 03, 2009, 08:04:39 AM
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

Title: Re: Define byte LengthOF
Post by: AgentSmithers on June 03, 2009, 09:07:27 AM
Thanks!
Title: Re: Define byte LengthOF
Post by: cobold on June 03, 2009, 12:15:58 PM
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
Title: Re: Define byte LengthOF
Post by: dedndave on June 03, 2009, 01:56:51 PM
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"
Title: Re: Define byte LengthOF
Post by: AgentSmithers on June 03, 2009, 04:18:34 PM
Ahh Thanks! All verry nice to know.