' Memory peek/poke operations: PEEK, POKE, PEEK$, POKE$
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL buffer AS STRING
    LOCAL addr AS LONG
    LOCAL b AS BYTE
    LOCAL w AS WORD
    LOCAL d AS DWORD

    buffer = "ABCDEFGHIJKLMNOP"
    addr = STRPTR(buffer)

    b = PEEK(BYTE, addr)
    PRINT "PEEK(BYTE):"; CHR$(b)

    w = PEEK(WORD, addr)
    PRINT "PEEK(WORD):"; FORMAT$(w, "&H")

    d = PEEK(DWORD, addr)
    PRINT "PEEK(DWORD):"; FORMAT$(d, "&H")

    POKE BYTE, addr + 1, 66
    PRINT "After POKE BYTE@+1:"; buffer

    PRINT "PEEK$:"; PEEK$(addr, 4)

    POKE$ addr + 4, "XXXX"
    PRINT "After POKE$@+4:"; buffer

    PRINT "Peek/poke operations complete."

    FUNCTION = 0
END FUNCTION
