Equivilent of unsigned char x[65535]; ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Godfrey

    Equivilent of unsigned char x[65535]; ?

    Hello. I plan to write a 6502 emulator using PHP.

    One thing I'd need is to to store 64k as the RAM. I suppose I could use an
    a PHP array, with integers 0..65535 as the index, but as the PHP is an
    associative array, it doesn't seem like the best storage.

    Another possibility could be to keep a 64k long string. Could PHP handle
    such a long string, including all possible byte values includind 0 and 255
    and everything inbetween?

    Perhaps there's a way to access a raw buffer of memory which I can't find
    in the documents.

    Any ideas please?

    Bill, why yes, I am quite mad!
  • Chung Leong

    #2
    Re: Equivilent of unsigned char x[65535]; ?


    "Bill Godfrey" <bill-godfrey@sunny-coventry.invali d> wrote in message
    news:2004062219 2445.812$c6@new sreader.com...[color=blue]
    > Hello. I plan to write a 6502 emulator using PHP.
    >
    > One thing I'd need is to to store 64k as the RAM. I suppose I could use an
    > a PHP array, with integers 0..65535 as the index, but as the PHP is an
    > associative array, it doesn't seem like the best storage.
    >
    > Another possibility could be to keep a 64k long string. Could PHP handle
    > such a long string, including all possible byte values includind 0 and 255
    > and everything inbetween?[/color]

    Yes, with no problem at all. I regularly use multi-megabyte strings.

    The preferred syntax of access a character within a string is $x{3445}. To
    get the actual byte value you need to use ord().


    Comment

    Working...