I am attempting to write some mac65 code that will watch a modem to find the state.
Use case: BBS program where a user unceremoniously hangs up; or if a program crashes and there is no recent activity on the modem because of that.
The idea is to run this as a TSR; and if the modem goes into a non-active state, execute a BASIC program.
My code does not work. It compiles to an OBJ file, and I can execute it - but as soon as I try to take a peek at the memory location to see what the state is froma BASIC program, the system crashes nastily.
1000 START:
1010 JSR OPEN_RS232
1020 JSR MONITOR_STATUS
1030 JSR CLOSE_RS232
1040 JMP END_PROGRAM
2000 OPEN_RS232:
2020 RTS
3000 CLOSE_RS232:
3020 RTS
4000 MONITOR_STATUS:
4010 LDX #2
4020 LDA #7
4030 STA IOCB2+2
4040 JSR XIO_COMMAND
4050 LDA $02EA
4060 STA STATUS_BYTE
4070 RTS
5000 XIO_COMMAND:
5010 JSR XIO_ENTRY
5020 LDA IOCB2+4
5030 CMP #0
5040 BNE HANDLE_ERROR
5050 RTS
6000 HANDLE_ERROR:
6010 LDX # <ERROR_MSG
6020 LDY # >ERROR_MSG
6030 JSR PRINT_STRING
6040 RTS
7000 PRINT_STRING:
7010 LDA #9
7020 STA IOCB2
7030 LDY #0
7040 JSR CIOV
7050 RTS
8000 ERROR_MSG:
8010 .BYTE "ERROR OCCURRED",$9B,0
9000 END_PROGRAM:
9020 RTS
10000 IOCB2 = $0350
10010 XIO_ENTRY = $E456
10020 CIOV = $E456
10030 STATUS_BYTE = $0680
11000 .END