3 ms·
10 REM TAN 20 PRINT USR 16514 16514
by klelatti 6y ago
10 REM TAN
20 PRINT USR 16514
16514
- rwmj 6y agoGood one. TAN (the keyword, not the 3 letters) is hex C9 which is also RET in Z80 machine code. The address of the first byte after the keyword in the first statement in a ZX81 program is 16514. USR 16514 calls this address, which immediately returns. The PRINT statement then prints the result of the USR expression, which is the contents of the BC register on return, which I guess happens to contain the start address (since not otherwise set) as a side effect of the implementation. 16509 is the address of the start of the program in memory. Bytes 16509-16510 are the line number (2 byte LSB int). Bytes 16511-16512 are the length of the line. Byte 16513 is the command keyword (REM).
- klelatti 6y agoAfter thirty odd years I still have these numbers encoded into and handful of neurons somewhere. Thank you for getting me to dig them out and great that they live on in libvirt! ps The memory mapping reminded me that ZX81 managed to squeeze a 32 x 24 screen into a 1k total RAM. I think someone managed to write a chess program with those restrictions - but only using 8 x 8 or so of the screen.
- rwmj 6y agoIndeed, 1K chess by David Horne: https://en.wikipedia.org/wiki/1K_ZX_Chess https://en.wikipedia.org/wiki/1K_ZX_Chess I had this chess game on tape, and I've often wondered if the two are related, but this one needed 16K: http://www.zx81stuff.org.uk/zx81/tape/ZXChessII(Black) http://www.zx81stuff.org.uk/zx81/tape/ZXChessII(Black)
- 2a0c40 6y agoNot only you!