Sets HL to point to the appropriate flow struct on the stack. On entry, if this was called by the NEXT keyword handler then DE is pointing to the variable following the NEXT keyword.
|The first four bytes on the stack are (or rather, should be) two return addresses. We're not interested in them, so the first thing to do is set HL to point to SP+4.|
|0192||210400||GetFlowPtr||LXI H,0004||HL=SP+4 (ie get word|
|0195||39||DAD SP||just past return addr)|
|Get the keyword ID, the byte that precedes the flow struct. Then we increment HL so it points to (what should be) the flow struct, and return if the keyword ID is not 'FOR'.|
|019A||C0||RNZ||Return if not 'FOR'|
|Special treatment for FOR flow structs. Here we check that we've got the right one, ie the one required by the NEXT statement which called us. When we're called by NEXT, it sets DE to point to the variable in the NEXT statement. So here we get the first word of the FOR flow struct which is the address of the FOR variable, and compare it to the one we've been given in DE. If they match, then we've found the flow struct wanted and we can safely return. If not then we jump 13 bytes up the stack - 13 bytes is the size of the FOR flow struct - and loop back to try again.|
|019B||F7||RST PushNextWord||PUSH (HL)|
|019C||E3||XTHL||POP HL (ie HL=(HL))|
|01A1||E1||POP H||Restore HL|
|01A2||C8||RZ||Return if var ptrs match.|
Copies a block of memory from BC to HL. Copying is done backwards, down to and including the point where BC==DE. It goes backwards because this function is used to move blocks of memory forward by as little as a couple of bytes. If it copied forwards then the block of memory would overwrite itself.
|Exchange BC with HL, so HL now points to the source and BC points to destination.|
|01AA||C5||PUSH B||Exchange BC with HL.|
|01B0||C8||RZ||Exit if DE reached.|
Checks that there is enough room for C*4 bytes on top of (VAR_TOP) before it intrudes on the stack. Probably varspace.
Checks that HL is more than 32 bytes away from the stack pointer. If HL is within 32 bytes of the stack pointer then this function falls into OutOfMemory.
|01C5||21DEFF||LXI H,FFDE||HL=-34 (extra 2 bytes for return address)|
Notice use of LXI trick.
Resets the stack, prints an error code (offset into error codes table is given in E), and stops program execution.
|01DF||3E3F||MVI A,'?'||Print '?'|
|01E2||19||DAD D||HL points to error code.|
|01E4||DF||RST OutChar||Print first char of code.|
|01E6||DF||RST OutChar||Print second char of code.|
|01E7||218101||LXI H,szError||Print " ERROR".|
|01F6||01....||LXI B,....||LXI over Stop and fall into Main|