Skrevet av Emne: C64: BASIC program storage in RAM  (Lest 2338 ganger)

ATC

  • Gjest
C64: BASIC program storage in RAM
« på: 27. ſeptember 2008, 18:24 pm »
  • [applaud]0
  • [smite]0
  • How is a BASIC program stored in the Commodore 64?



    ATC

    • Gjest
    [Solved] C64: BASIC program storage in RAM
    « Svar #1 på: 27. ſeptember 2008, 18:24 pm »
  • [applaud]0
  • [smite]0
  • The BASIC program code always* starts with a byte #$00 at $0800, followed by one or more records in the following format:

    NEXT LOW (byte)
    NEXT HIGH (byte)
    BASIC line number LOW (byte)
    BASIC line number HIGH (byte)
    Bytecode ASCIIZ string, bytes > #$80 are instruction codes

    Example code:
    0800: 00 0c 08 01 00 9e 20 34
    0808: 30 39 36 00 00 00

    Code breakdown:
    0800: 00 # Always* zero
    0801: 0c 08 # Next record begins at $080c
    0803: 01 00 # Line number 1
    0805: 9e 20 34 30 39 36 # SYS 4096
    080b: 00 # ASCIIZ string terminator
    080c: 00 00 # Next record begins at $0000 (End of program)

    *) The first byte is always zero in the code I have examined. If this byte is changed, the BASIC interpreter will yield syntax errors but still run the code that follows.