SIO help needed

General discussions related to the Altair 8800 Clone

SIO help needed

Postby smp » April 29th, 2014, 5:22 pm

Hello all,

I have been experimenting with my Altair clone. I am trying to produce some code that will take input from the console keyboard and echo it verbatim out the second serial I/O port. This is a preamble to being able to have a program send output to some other display device while still having the console attached to my normal laptop running TerraTerm.

Anyway, I thought this would be an easy one to start with. I grabbed the source file for PCGET.ASM because I was going to strip out all the XMODEM stuff, and all I was really after was the proper way to initialize the Altair SIO ports.

Here is my code:

Code: Select all
;
                ;  SIO-EXPR - THIS PROGRAM TAKES INPUT FROM THE CONSOLE PORT
                ;  AND SENDS THE INPUT VERBATIM OUT SERIAL PORT B.
                ;
                ;  SERIAL PORT EQUATES
               
 0010 =         SIOACR   EQU   010H      ;2SIO PORT A CONTROL REGISTER
 0011 =         SIOADR   EQU   011H      ;2SIO PORT A DATA REGISTER
 0012 =         SIOBCR   EQU   012H      ;2SIO PORT B CONTROL REGISTER
 0013 =         SIOBDR   EQU   013H      ;2SIO PORT B DATA REGISTER
               
 0002 =         MODEM$SEND$MASK   EQU   2
 0002 =         SEND$READY   EQU   2   ;VALUE WHEN READY
 0001 =         MODEM$RECV$MASK   EQU   1
 0001 =         RECV$READY   EQU   1   ;BIT ON WHEN READY
               
                ;  TRANSFER RELATED EQUATES
               
 0001 =         SOH   EQU   1
 0004 =         EOT   EQU   4
 0006 =         ACK   EQU   6
 0015 =         NAK   EQU   15H
 0003 =         CTRLC   EQU   3         ;CONTROL-C
 000A =         LF   EQU   10
 000D =         CR   EQU   13
               
 0100              ORG   100H
                   
                ;  SWITCH TO LOCAL STACK AND DO THE TRANSFER
               
 0100 210000    DOXFER   LXI   H,0      ;HL=0
 0103 39           DAD   SP      ;HL=STACK FROM CP/M
 0104 224702       SHLD   STACK      ;SAVE IT
 0107 314702       LXI   SP,STACK   ;SP=MY STACK
 010A CD4D01       CALL   INIT$ACIA   ;MASTER RESET THE ACIA
 010D 115A01       LXI   D,MSEND      ;POINT TO SIGN ON MESSAGE
 0110 0E09         MVI   C,PRINT      ;PRINT THE SEND MESSAGE
 0112 CD0500       CALL   BDOS      ;PRINT ID MESSAGE
               
 0115 CD2E01    LOOP   CALL   RECV
 0118 FE03         CPI   CTRLC      ;EXIT IF ABORT REQUESTED
 011A CA0602       JZ   ABORT
 011D CD3F01       CALL   SEND
 0120 C31501       JMP   LOOP
                ;
                ; S U B R O U T I N E S
                ;
                ; - - - - - - - - - - - - - - -
               
                ;EXIT PRINTING MESSAGE FOLLOWING 'CALL ERXIT'
               
 0123 D1        ERXIT   POP   D      ;GET MESSAGE
 0124 0E09         MVI   C,PRINT
 0126 CD0500       CALL   BDOS      ;PRINT MESSAGE
 0129 2A4702    EXIT   LHLD   STACK      ;GET ORIGINAL STACK
 012C F9           SPHL         ;RESTORE IT
 012D C9           RET         ;--EXIT-- TO CP/M
               
                ; - - - - - - - - - - - - - - -
                ;SIO RECV FROM CONSOLE
                ;-------------------------------------
 012E D5        RECV   PUSH   D      ;SAVE
               
                ;  PORT A INPUT
               
 012F DB10      MWTI   IN   SIOACR
 0131 E601         ANI   MODEM$RECV$MASK
 0133 FE01         CPI   RECV$READY
 0135 CA3B01       JZ   MCHAR      ;GOT CHAR
 0138 C32F01       JMP   MWTI
               
                ;  GOT AN INPUT FROM CONSOLE
               
 013B DB11      MCHAR   IN   SIOADR
 013D D1           POP   D      ;RESTORE DE
 013E C9           RET
               
                ; - - - - - - - - - - - - - - -
                ;SIO SEND CHAR TO PORT B
                ;----------------------------------
                ;
 013F F5        SEND   PUSH   PSW      ;SAVE THE OUTPUT CHARACTER
               
 0140 DB12      SENDWB   IN   SIOBCR
 0142 E602         ANI   MODEM$SEND$MASK
 0144 FE02         CPI   SEND$READY
 0146 C24001       JNZ   SENDWB
 0149 F1           POP   PSW      ;GET CHAR
 014A D313         OUT   SIOBDR
 014C C9           RET
               
                ; INITITIALIZE THE SERIAL PORT
               
                INIT$ACIA:
               
                ; INITA - INIT PORT A
               
                ;   MVI   A,003H      ;DON'T RESET CONSOLE PORT
                ;   OUT   SIOACR
 014D 3E15         MVI   A,015H      ;RTS ON, 8N1
 014F D310         OUT   SIOACR
               
                ; INITB - INIT PORT B
               
 0151 3E03      INITB   MVI   A,3   
 0153 D312         OUT   SIOBCR
 0155 3E15         MVI   A,015H      ;RTS ON, 8N1
 0157 D312         OUT   SIOBCR
 0159 C9           RET
               
 015A 0D0A4C4953MSEND   DB   CR,LF,'LISTENING ON CONSOLE PORT, SENDING TO PORT B...',CR,LF,LF,'$'
               
 018F 0D0A504347MHELP   DB   CR,LF,'PCGET VER 1.1',CR,LF,LF
 01A1 5553414745   DB   'USAGE: PCGET FILE.EXT [B]',CR,LF
 01BC 2020202020   DB   '       (B SPECIFIES 2SIO PORT B FOR TRANSFER)',CR,LF,'$'
               
                ;DONE - CLOSE UP SHOP
               
                XFER$CPLT:
 01EC CD2301       CALL   ERXIT
 01EF 0D0A0A5452   DB   13,10,10,'TRANSFER COMPLETE',13,10,'$'
               
 0206 CD2301    ABORT:   CALL   ERXIT
 0209 0D0A0A5452   DB   13,10,10,'TRANSFER ABORTED',13,10,'$'
               
 021F              DS   40   ;STACK AREA
 0247           STACK   DS   2   ;STACK POINTER
 0249           RSECTNO   DS   1   ;RECEIVED SECTOR NUMBER
 024A           SECTNO   DS   1   ;CURRENT SECTOR NUMBER
 024B           FPORTB   DS   1   ;FLAG TO USE 2SIO PORT B INSTEAD OF A
                ;
                ; BDOS EQUATES (VERSION 2)
                ;
 0001 =         RDCON   EQU   1
 0002 =         WRCON   EQU   2
 0009 =         PRINT   EQU   9
 000B =         CONST   EQU   11   ;CONSOLE STAT
 000F =         OPEN   EQU   15   ;0FFH=NOT FOUND
 0010 =         CLOSE   EQU   16   ;   "   "
 0011 =         SRCHF   EQU   17   ;   "   "
 0012 =         SRCHN   EQU   18   ;   "   "
 0013 =         ERASE   EQU   19   ;NO RET CODE
 0014 =         READ   EQU   20   ;0=OK, 1=EOF
 0015 =         WRITE   EQU   21   ;0=OK, 1=ERR, 2=?, 0FFH=NO DIR SPC
 0016 =         MAKE   EQU   22   ;0FFH=BAD
 0017 =         REN   EQU   23   ;0FFH=BAD
 001A =         STDMA   EQU   26
 0005 =         BDOS   EQU   5
 0000 =         REIPL   EQU   0
 005C =         FCB   EQU   5CH   ;DEFAULT FCB
 005D =         PARAM1   EQU   FCB+1   ;COMMAND LINE PARAMETER 1 IN FCB
 006D =         PARAM2   EQU   PARAM1+16   ;COMMAND LINE PARAMETER 2
 024C              END


You can see the LOOP in the middle there, simply a CALL RECV, check for CTRL-C, then CALL SEND.

You can also see the SIO initialization that is the pertinent pieces taken from the original PCGET.ASM.

You can also see that I have not fully stripped out a bunch of stuff left over from PCGET.ASM. That cleanup was to come later when I start to fill in whatever I come up with next.

None of this is a big deal, but it does not work!

When I have my two laptops hooked up, the console operates like it is supposed to, showing the LISTENING ON CONSOLE PORT, SENDING TO PORT B... message after I execute the program, then not showing any other keystrokes because they're being sent off to port B. Except, nothing shows up on my other laptop computer running Hyperterminal. When I type CTRL-C on the console, I properly get the TRANSFER ABORTED message, and the console returns to CP/M.

So, what's wrong with this picture? I am using tried and true cables, and both laptop computers function properly if I use them as my console device, so I am left wondering about my code. Can anyone take a look at the code and tell me if I have some obvious error? I do not have experience using an Altair 2-SIO board before. All my SIO experience is with more programmable devices such as the 8251 or the Z85C30 chip used on the SIO board from http://www.s100computers.com.

Thanks, in advance, for any suggestions that you may be able to make.

smp
smp
 
Posts: 12
Joined: March 12th, 2014, 6:45 pm

Re: SIO help needed

Postby AltairClone » April 29th, 2014, 6:42 pm

The code looks reasonable.

Go into the Configuration Monitor under Serial Ports and verify that the second serial port in the Clone is configured as a 2SIO port (not SIO) at octal 22/23, 9600 baud and that CTS and RTS are not used.

Mike
AltairClone
Site Admin
 
Posts: 421
Joined: April 5th, 2013, 10:55 am

Re: SIO help needed

Postby smp » April 29th, 2014, 8:14 pm

OK! That did the trick. Port B was set as an SIO, not the 2-SIO.

Thanks a million for your help, Mike.

So now, here's my next question:

I noticed that the code I posted was calling the SIO ports as 10 & 11 and 12 & 13. So, I changed the code to call them 20 & 21 and 22 & 23. Then I saw the comment marks in the code for not doing a reset on the console port, so I went further and commented out all the ACIA setup, assuming that it would already be there from the system setup.

Wrong! That code did not work at all.

So, I put the code back to calling the SIO ports 10 & 11 and 12 & 13, and I un-commented the setup byte for port A (as it was before) and I took the comment marks off of the port B code (as it was before), and I am back to working again.

I thought that the ports would be all set up by the system initialization so I wouldn't actually have to do anything, but that was not so. Now I am looking at code that talks to the wrong port locations, but the code works...

I am all confused.

smp
smp
 
Posts: 12
Joined: March 12th, 2014, 6:45 pm

Re: SIO help needed

Postby AltairClone » April 29th, 2014, 11:02 pm

The Clone menus use the MITS convention of octal for the port addresses. The code you are using is using hex constants. For example, port 20 in octal is the same as port 10 expressed in hex.

The ACIA reset for port 10 was commented out in the code because CP/M already initialized the console serial port during cold boot. The 2nd port at 12 hex is not initialized by CP/M, so the code must do it.

Mike
AltairClone
Site Admin
 
Posts: 421
Joined: April 5th, 2013, 10:55 am

Re: SIO help needed

Postby smp » April 30th, 2014, 6:18 am

Hi again, Mike,

YIKES! I am embarrassed, for sure.

The same binary bit pattern but differing representations caught me, big time.

Thank you very much for your patient explanation. I was really stuck on this silly misinterpretation.

Thanks also for the explanation that Port B is not set up by CP/M. I should have figured that one out, too.

smp
smp
 
Posts: 12
Joined: March 12th, 2014, 6:45 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests