rickcollette Posted December 2, 2023 Share Posted December 2, 2023 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 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted December 2, 2023 Share Posted December 2, 2023 Shouldn't the X register hold the IOCB number * 16 from your code, the X register is holding the value 2 instead of 32 ($20) Quote Link to comment Share on other sites More sharing options...
phaeron Posted December 2, 2023 Share Posted December 2, 2023 Several problems: MONITOR_STATUS passes X=2 to CIOV. This is an invalid value; X should be set to $10*IOCB#, so for IOCB#2 it would be X=$20. IOCB#2 isn't opened to any device before the status command is issued. You can do this by an "implied OPEN", but it requires pointing ICBAL,X and ICBAH,X to the device name (presumably R:). IOCB2 actually points to IOCB #1. IOCB#0 starts at $0340, IOCB#1 at $0350, and IOCB#2 at $0360. XIO_COMMAND is trying to read the buffer address low byte (ICBAL) instead of result status (ICSTA), and treats all non-zero status values as errors. Success is indicated by a positive number with $01 in most cases, with a few other values occasionally ($03 in particular from DOS). PRINT_STRING writes the $09 command byte into the device ID byte of IOCB#1 instead of the command byte of IOCB#0, and sets Y=0 instead of X=0 to select IOCB#0. HANDLE_ERROR doesn't write its string address into the ICBAL/ICBAH fields that would be necessary to tell CIO the address of the buffer to write. You have to set a maximum buffer length for the PUT RECORD command ($09) in ICBLL/ICBLH. CIO stops either after the EOL or at the end of the buffer, whichever comes first. Quote Link to comment Share on other sites More sharing options...
rickcollette Posted December 3, 2023 Author Share Posted December 3, 2023 awesome - I am digging in using you folks comments. I have applied some - and I'm getting freezing, but it does seem to get past some of the earlier issues. Quote Link to comment Share on other sites More sharing options...
rickcollette Posted December 4, 2023 Author Share Posted December 4, 2023 I think im gonna step away from this. Super far out of my element. Really - I just want a way to make sure a modem is working properly and still connected while loading and unload basic programs. If it could be extended to also hold some string values i can read via USR/PEEK, that would be excellent. However, this is just so far outside my skillset - I think Ill try to find another approach Appreciated the help here. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted December 4, 2023 Share Posted December 4, 2023 1 hour ago, rickcollette said: However, this is just so far outside my skillset - I think Ill try to find another approach @rickcollette Could try this from BASIC, you can do what you wanted before but using PEEK and POKE plus a USR call have a look at this listing, not tried it as I don't have an "R:" device, but I think the basics (excuse the pun) are there. 1 REM SIMPLE BASIC PROGRAM TO OPEN 2 REM R: DEVICE, THEN SET PARAMETERS 3 REM WITH POKES, THEN USE USR ROUTINE 4 REM TO CALL CIO 5 REM USR=PLA PLA PLA TAX JSR E456 RTS 10 DIM A$(8):RESTORE 1000 15 REM USR ROUTINE TO CALL CIO 20 FOR I=1 TO 8:REM INSERT INTO A$ 30 READ A:A$(I,I)=CHR$(A) 40 NEXT I 50 CLOSE #2:REM JUST IN CASE IT'S OPEN 60 OPEN #2,12,0,"R:":REM OPEN R/W 70 REM POKE PARAMETERS INTO IOCB2 80 REM ADDRESS 864 TO 879 90 REM THEN USE:- 100 REM X=USR(ADR(A$),32) 110 REM TO CALL CIOV 120 REM YOU CAN THEN PEEK(746) FOR 130 REM THE STATUS BYTE (DVSTAT) 900 CLOSE #2:REM REMEMBER TO CLOSE 999 REM USR DATA 1000 DATA 104,104,104,170,32,86,228,96 Quote Link to comment Share on other sites More sharing options...
rickcollette Posted December 4, 2023 Author Share Posted December 4, 2023 this is perfect - I just need a way to create a persisted set of data across loading various programs. ex: run program1.bas - this would load in a config file, stuff some values into peekaboo memory - provide a menu the user can select from - assume user selects "program2.bas" program2.bas - Reads data from memory locations set by program1 - maybe update those locations with its own information - user can return to program1 program3.bas - same thing as 2.. and so on. use case: with a bbs, AMP and MOE did this - however the source to those is unavailable, and if it were, I don't think "we" have permission to mod and use it. So - id like a startup program that reads and sets info to memory locations. - launch additional programs that use that data - information that would need to persist without having to recode everything to read a drop file or some such thing - I *COULD* use drop files that contain the data.. but what a PITA to have to rewrite all that code for each additional program... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.