PEEK and POKE - Peek and Poke in BBC BASIC

Peek and Poke in BBC BASIC

BBC BASIC, used on the BBC Micro and other Acorn Computers machines, did not feature the keywords PEEK and POKE but used the question mark symbol (?), known as query in BBC BASIC, for both operations, as a function and command. For example:

> DIM W% 4 : REM reserve 4 bytes of memory, pointed TO by INTEGER variable W% > ?W% = 42 : REM store constant 42; equivalent of 'POKE W%, 42' > PRINT ?W% : REM PRINT the byte pointed TO by W%; equivalent of 'PRINT PEEK(W%)' 42

32-bit values could be POKEd and PEEKed using the exclamation mark symbol (!), known as pling, with the least significant byte first (little-endian). In addition, the address could be offset by specifying either query or pling after the address and following it with the offset:

> !W% = &12345678 : REM ampersand (&) specifies hexadecimal > PRINT ~?W%, ~W%?3 : REM tilde (~) prints in hexadecimal 78 12

Strings of text could be PEEKed and POKEd in a similar way using the Dollar sign ($). The end of the string is marked with the Carriage return character (&0D in ASCII); when read back, this terminating character is not returned. Offsets cannot be used with the dollar sign.

> DIM S% 20 : REM reserve 20 bytes of memory pointed TO by S% > $S% = "MINCE PIES" : REM store STRING 'MINCE PIES', terminated by &0D > PRINT $(S% + 6) : REM retrieve STRING, termined by &0D started at S% + 6 bytes PIES

Read more about this topic:  PEEK And POKE

Famous quotes containing the words peek, poke, bbc and/or basic:

    I’ve stayed in the front yard all my life.
    I want a peek at the back
    Where it’s rough and untended and hungry weed grows.
    A girl gets sick of a rose.
    Gwendolyn Brooks (b. 1917)

    I drink the five o’clock martinis
    and poke at this dry page like a rough
    goat. Fool! I fumble my lost childhood
    for a mother and lounge in sad stuff
    with love to catch and catch as catch can.
    Anne Sexton (1928–1974)

    The word “conservative” is used by the BBC as a portmanteau word of abuse for anyone whose views differ from the insufferable, smug, sanctimonious, naive, guilt-ridden, wet, pink orthodoxy of that sunset home of the third-rate minds of that third-rate decade, the nineteen-sixties.
    Norman Tebbit (b. 1931)

    Mental health depends upon the maintenance of a balance within the personality between the basic human urges and egocentric wishes on the one hand and the demands of conscience and society on the other hand.
    Selma H. Fraiberg (20th century)