Announcement

Collapse
No announcement yet.

Longest an ASCIIZ String Can Be?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Longest an ASCIIZ String Can Be?

    What is the longest that an Asciiz string can be? I was trying to
    create a 1 megabyte Asciiz string and it causes a Stack fault in
    Windows. The most I can make it is around 200 KB. Anyone have any
    info on this?


    Scott


    ------------------
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

  • #2
    LOCAL scalar (non-array) variables are created within the stack frame, which limits them to below 1Mb (except dynamic strings because only the handle is stored on the stack). To create larger ASCIIZ or fixed-length strings, make them GLOBAL or STATIC.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Following from the technical data that Lance has provided, if you
      do use a GLOBAL or STATIC ASCIIZ string, your program will increase
      in size by the amount that you allocate that way.

      Unless you have a very good reason to do that, I would be inclined
      to work with dynamic string or GlobalAlloc() style memory as it
      does not blow out the size of your EXE file.

      The BYCOPY operator in PowerBASIC allows you to use basic dynamic
      string where an API call requires a string address so I would be
      inclined to look for another way to do what you are after.

      Regards,

      [email protected]

      ------------------
      hutch at movsd dot com
      The MASM Forum - SLL Modules and PB Libraries

      http://www.masm32.com/board/index.php?board=69.0

      Comment


      • #4
        Originally posted by Steve Hutchesson:
        Following from the technical data that Lance has provided, if you
        do use a GLOBAL or STATIC ASCIIZ string, your program will increase
        in size by the amount that you allocate that way.
        I wanted to test this, so I made the following program:
        Code:
        #Compile Exe
         
        Global bigString As Asciiz*16777216
         
        Function PbMain()
            MsgBox "HI"
        End Function
        Steve seems to be correct on this.
        Mem usage grows to 17 Mb.
        Filesize is 5.0 KB

        PS: using any number larger than 16777216, gives a "Integer constant expected" error from the compiler (PB6)


        ------------------
        Best Regards
        Peter Scheutz

        [This message has been edited by Peter Scheutz (edited August 08, 2001).]
        Best Regards
        Peter Scheutz

        Comment


        • #5
          It's necessary to make dynamic string.
          For most operations (=, Mid$ and so on) long Asciiz are bad, because PB searches 0.

          ------------------
          E-MAIL: [email protected]

          Comment


          • #6
            If you want a LOCAL large ASCIIZ string, you can:

            Code:
            FUNCTION Foo
            
              REDIM szFoo(0) AS ASCIIZ * 2000000
            
            END FUNCTION
            For arrays it seems only the descriptor comes out of the stack and the dataspace comes out of the far heap (i.e., the GlobalAlloc family)

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X