←back to thread

322 points DamonHD | 6 comments | | HN request time: 0.002s | source | bottom
Show context
sokoloff ◴[] No.41829570[source]
RIP.

My first paid programming gig ($20) was implementing the XMODEM checksum in 6502 assembly for a BBS sysop who had bought an early 1200 baud modem, only to find that his Atari BASIC BBS software was computing the checksum so slowly that it still created slowdowns in file transfers and needed a USR() that could compute it faster.

I learned a lot about protocols and algorithms from that exercise (now trivially simple, but wasn't for me at the time).

replies(2): >>41830789 #>>41832746 #
1. fsckboy ◴[] No.41830789[source]
>an early 1200 baud modem...needed a USR()

what's a USR()?

asking cuz USRobotics was a modem company

replies(2): >>41830813 #>>41830825 #
2. compressedgas ◴[] No.41830813[source]
> USR is a BASIC function to call (execute) a machine code routine
replies(1): >>41831263 #
3. renewedrebecca ◴[] No.41830825[source]
Usr() is a way to call out to a machine (assembly) language subroutine from BASIC.
4. sokoloff ◴[] No.41831263[source]
This. I'll add the following reference in case someone is curious and wants more details:

https://www.page6.org/archive/issue_11/page_24.htm

One of the annoying things is that the most convenient way to encode a short machine code subroutine was in a BASIC string. But BASIC strings are not loaded in a predictable location in RAM, so any code intended to be encoded in a BASIC string has to be relocatable (using only relative branches/jumps). That's not an issue for a simple XMODEM checksum calculation, of course.

replies(1): >>41837424 #
5. rwmj ◴[] No.41837424{3}[source]
Obscure facts ...

On the Sinclair computers (incredibly popular in the UK, the BASIC was not written by Microsoft) it was in fact possible to predict where the program would be loaded, so a very popular place to store machine code was in a REM statement. This also had the advantage that you could save the machine code by saving the BASIC program.

On the ZX81, the first byte of the payload of a REM statement at the beginning of the program was at address 16514, hence:

  RAND USR 16514
was the command to run the machine code. (RAND set the random number seed and was just used as a convenient way to turn the USR function into a BASIC statement. The contents of the BC register were the return value from USR).
replies(1): >>41856829 #
6. dogline ◴[] No.41856829{4}[source]
That's what it was! As a kid I had the TRS-80 Coco, related to the Sinclair, and I remember one of those graphing programs you typed in from Rainbow magazine, and I think it was able to plot the equation you had in a REM statement, that also had to be on a particular line number. There was a statement at the top of the program, like what you have here (maybe a POKE?), and I always knew it did something magical to be able execute from a REM statement, but I could never put it together.

The Star Trader game was also really ahead of its time.

There was no Google, and I've forgotten about it until just now. But, that makes sense. Thanks.