A Newbie Writes...

General discussions related to the Altair 8800 Clone

A Newbie Writes...

Postby mcgarrett » June 15th, 2015, 2:46 pm

Hi All,

I took delivery of my Altair Clone about 3 weeks ago (thanks Mike) and am having a lot of fun just dabbling with it as a complete novice. I've done the exercises in the Altair Clone manual and am seeing what else I can mess around with.

I was looking at the following simple program to test the 2SIO with TeraTerm (courtesy of http://www.solivant.com/altair_bootload ... rs&pagen=1), which echoes out received input:

Code: Select all
000:   076 003 323 020 076 021 323 020
010:   333 020 017 322 010 000 333 021
020:   323 021 303 010 000


init:   mvi   A, 003   ; Reset the 2SIO port 1
   out   020
   mvi   A, 021   ; Set port 1 to 8,2,n
   out   020

loop:   in   020   ; wait for a character to arrive
   rrc
   jnc   loop

   in   021   ; get the character
   out   021   ; send it back out
   jmp   loop   ; continue forever


Out of idle curiosity, I got to thinking it should be possible to take the input from the sense switches instead of the terminal and output that to the terminal. IIRC I changed the 021 for 377 on the input instruction (one or both, can't remember and am working away so can't test just now) and tried it out. My guess was I would be able to set values in the sense switches and have the ascii equivalent show up in the terminal. It sort of worked, echoing characters based on the sense switch values, but it only seemed to output when A8 switch was set to 1.

Anyone care to explain to an absolute beginner why this should be, or (teach a man to fish) point me in the right direction as to an explanation?

Cheers,

Jim
mcgarrett
 
Posts: 2
Joined: May 9th, 2015, 3:10 am

Re: A Newbie Writes...

Postby AltairClone » June 15th, 2015, 9:18 pm

You probably changed both input instructions. This would cause the program to hang in "loop" until A8 is set.

If you change just the second input (in 021), it should work as you expect. In this case, the program reads and transmits the sense switch character each time you type a character on the keyboard.

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

Re: A Newbie Writes...

Postby jdrago » June 15th, 2015, 10:31 pm

Hi Jim,

I've taken the original program and added line numbers with comments below:

1 init: mvi A, 003 ; Reset the 2SIO port 1
2 out 020
3 mvi A, 021 ; Set port 1 to 8,2,n
4 out 020
5
6 loop: in 020 ; wait for a character to arrive
7 rrc
8 jnc loop
9
10 in 021 ; get the character
11 out 021 ; send it back out
12 jmp loop ; continue forever


The first 2SIO port on the Altair 8800 Clone is set to addresses 020 and 021 (octal) by default. I assume that you have not changed this. These addresses are 0x10 and 0x11 respectively in hexadecimal. The first address, 020, is a status register when read. It is a control register when written.

The second address, 021, is a receive data register when read. It is a transmit data register when written.


lines 1 & 2: Reference the Motorola ACIA MC6850 datasheet. The lower two bits of the control register are CR1 and CR0. When the lower two bits are set to '1', the MC6850 performs a master reset.
Background:3 = 0000 0011 (in hex. I think in hex better than octal). 3 = 00 000 011 (in octal)

lines 3 & 4: 21 = 00 010 001 (octal). This will set bits 4 and 0 to a '1'. Bit 4 is CR4. This along with CR3 and CR2 (both zero) from the data sheet means set the port for 8 data bits plus 2 stop bits. Bit 0 is CR0. That along with CR1 which is zero, selects 'divide by 16' mode for the baud clock. Take the master clock going to the MC6850, divide by 16, this should yield the bit clock for 9600 baud (about 104 microseconds? My memory may be a little off...)

lines 6, 7, & 8: This is the heart of your issue with changing the program. Line 6 reads the status register into A. Bit 0 of the status register is Receive Data Register Full (RDRF). This bit will be a '1' when a character has been received. Line 7 is a fast way to check if bit 0 is set. The instruction 'rrc' rotate right through carry will shift all bits in A right 1 bit, and put bit 0 into the Carry Flag. Line 8 contains a jump no carry back to the wait loop. So, if there was no character ready, then A's bit 0 would be '0'. After the 'rrc' instruction, the carry would also be '0'. The jump in line 8 would be executed in this case.

line 10: Read the received character from the Receive Data Register into A.

line 11: Write the character in A to the Transmit Data Register.


NEW PROGRAM:

Code: Select all
0100                   org     100h
               
0100 C30B01            jmp     loop            ; if running from CP/M, don't init the port
               
0103 3E21      init:   mvi     A, 33           ; Reset the 2SIO port 1
0105 D310              out     020Q
0107 3E11              mvi     A, 021Q         ; Set port 1 to 8,2,n
0109 D310              out     020Q
               
010B DBFF      loop:   in      377Q            ; read sense switches
010D FE00              cpi     0               ; all zeroes?
010F CA0B01            jz      loop
               
0112 47                mov     b, a            ; save the switches in B
               
0113 DB10      wait:   in      020Q            ; check status register
0115 E602              ani     002             ; transmit data register empty?
0117 CA1301            jz      wait            ; if not, wait
               
011A 78                mov     a, b            ; get the switches back in A
               
011B D311              out     021Q            ; write the value to the serial port
               
011D FEFF              cpi     377Q            ; all ones?
011F C8                rz                      ; gracefully return to CP/M if all sense switches A15-A8 are 1's
               
0120 C30B01            jmp     loop


I hope this helps.
John
jdrago
 
Posts: 3
Joined: May 30th, 2015, 9:46 pm

Re: A Newbie Writes...

Postby mcgarrett » June 17th, 2015, 1:29 pm

Mike, John,

Thanks very much for your help, really appreciated.

John, on the back of that I've had a look at the 2SIO hardware manual and the data sheet you mentioned with a view to getting my head round things.

As I say, I'm a complete novice so it's fun having something like this to tinker with.

Cheers,

Jim
mcgarrett
 
Posts: 2
Joined: May 9th, 2015, 3:10 am

Re: A Newbie Writes...

Postby jdrago » June 17th, 2015, 6:27 pm

Jim,

I'm glad to help. The hardware manual should really help. I've included a link below for a Theory of Operation manual.

http://www.s100computers.com/Hardware%20Manuals/MITS/MITS%2088-2SIO%20Board.pdf

Best Wishes,
John
jdrago
 
Posts: 3
Joined: May 30th, 2015, 9:46 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron