A Use for DATA statements not found by RTFM...
BASIC is handy, and believe it or not, many of the I2C & SPI peripherals out there
these days can be interfaced to the '74 with PEEKS & POKES alone - This is usually
so slow that you'll quickly see the point of assembly language subroutines.
RS-232 can also be "bit-banged" with assembler - 19.2K is achievable.
Reserving memory with GETMEM, POKE-ing in an asm routine, & EXEC-ing it is pretty
straightforward - The CC40 User Manual has an example in the appendix. If you are,
say, interrogating a sensor, you also need a way to pass the data back to BASIC.
There is a formal mechanism for "parameter passing", of course, but if your asm
routine just passes data to your BASIC pgm, an easy hack is:
Make "100 DATA ##########" the first line in your BASIC program - This reserves
a 10-byte buffer (in this case) at a known location in memory, 0x3FF5 - 0x3FEC;
BASIC pgms run backwards in memory - From high address to low address.That high
address is normally 0x3FFF, 0x5FFF, or 0xBFFF.
If an 8K RAM cartridge is appended, the buffer address is 0x5FF5 - 0x5FEC. If a
32K RAM cartridge is appended, 0xBFF5 - 0xBFEC.
Your asm routine simply writes data to the buffer and returns. BASIC then READs
the DATA statement into a string and PRINT's it, or processes it further with SEG$,
ASC, VAL, and so on, depending on what you're up to.
Note that about half the possible chars (0 - 255) are non-printing characters;
the DATA statement may look a little strange after your asm routine writes raw
data to it, but BASIC's string functions process non-printing & printing chars
alike.
This might be all you need to add a Real-Time Clock, Temp sensor, Accelerometer,
or GPS to your '74...
Have fun!
BASIC is handy, and believe it or not, many of the I2C & SPI peripherals out there
these days can be interfaced to the '74 with PEEKS & POKES alone - This is usually
so slow that you'll quickly see the point of assembly language subroutines.
RS-232 can also be "bit-banged" with assembler - 19.2K is achievable.
Reserving memory with GETMEM, POKE-ing in an asm routine, & EXEC-ing it is pretty
straightforward - The CC40 User Manual has an example in the appendix. If you are,
say, interrogating a sensor, you also need a way to pass the data back to BASIC.
There is a formal mechanism for "parameter passing", of course, but if your asm
routine just passes data to your BASIC pgm, an easy hack is:
Make "100 DATA ##########" the first line in your BASIC program - This reserves
a 10-byte buffer (in this case) at a known location in memory, 0x3FF5 - 0x3FEC;
BASIC pgms run backwards in memory - From high address to low address.That high
address is normally 0x3FFF, 0x5FFF, or 0xBFFF.
If an 8K RAM cartridge is appended, the buffer address is 0x5FF5 - 0x5FEC. If a
32K RAM cartridge is appended, 0xBFF5 - 0xBFEC.
Your asm routine simply writes data to the buffer and returns. BASIC then READs
the DATA statement into a string and PRINT's it, or processes it further with SEG$,
ASC, VAL, and so on, depending on what you're up to.
Note that about half the possible chars (0 - 255) are non-printing characters;
the DATA statement may look a little strange after your asm routine writes raw
data to it, but BASIC's string functions process non-printing & printing chars
alike.
This might be all you need to add a Real-Time Clock, Temp sensor, Accelerometer,
or GPS to your '74...
Have fun!