Return-Path: <mattislind@gmail.com>
Delivered-To: craig@sbc-85.com
Received: from gator4254.hostgator.com
	by gator4254.hostgator.com with LMTP
	id +I4AGU4VK2Q8DAEAcizydQ
	(envelope-from <mattislind@gmail.com>)
	for <craig@sbc-85.com>; Mon, 03 Apr 2023 13:05:02 -0500
Return-path: <mattislind@gmail.com>
Envelope-to: craig@sbc-85.com
Delivery-date: Mon, 03 Apr 2023 13:05:02 -0500
Received: from mail-pg1-f175.google.com ([209.85.215.175]:35445)
	by gator4254.hostgator.com with esmtps  (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
	(Exim 4.95)
	(envelope-from <mattislind@gmail.com>)
	id 1pjOY9-000LX4-Sw
	for craig@sbc-85.com;
	Mon, 03 Apr 2023 13:05:02 -0500
Received: by mail-pg1-f175.google.com with SMTP id d22so18049453pgw.2
        for <craig@sbc-85.com>; Mon, 03 Apr 2023 11:04:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20210112; t=1680545090; x=1683137090;
        h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
         :date:message-id:reply-to;
        bh=RCJoQHtus2VExuDrlqgQV1XNm3GNWiD7Q1uB/pKKNiA=;
        b=oV71PdT4RCj7+wwpIakH9pqdBHrvQaWxRe462V7qbW3wKYnlL+v5SSOjeSMnsjv203
         TegMZolQvAIOwnCWU3gYrLgPHjXgMcxAclZhKXL8/gArW44mBPUVFqeMlg7mK+i4ehpe
         0nzF7QBBRiRQXSAv5yddbejKoW2b78MnLYwgW9tZmw0mdung3V6KxYpqY+3IODEAb2hd
         xMozHEKPMKfLk3dCXZJCYlAPC1eQ4Nc/t1LRR6955GM2mLZ+donrBaYfejblbBTZoSvA
         8+RU97yC96nuhUs5HEyS3DTjgNxq3EL0CBcwCiSJk2bZogUvd16Ieyi9SSBydu5IaFft
         8g5Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20210112; t=1680545090; x=1683137090;
        h=to:subject:message-id:date:from:mime-version:x-gm-message-state
         :from:to:cc:subject:date:message-id:reply-to;
        bh=RCJoQHtus2VExuDrlqgQV1XNm3GNWiD7Q1uB/pKKNiA=;
        b=F/E+ynX0dYkwxoCOwLjHg44ARtyPRfRuAd42Z0q61NpP0W8syvocYyO10Zf71Vc6Hl
         WAho9v3bJo6jS2E80MngZpM/WjCU5+GyP9UMl4KG5U3napTte5rFozOjseCwsWBmkHv9
         zVScSvGcjZElgDO2a6LKYWUPpmi/znWCdAd1sAJPfQ6Ih2zurFssCMuES1UIlKXhIu7F
         +zmdHGUf9TG+aB1ieNPxyCIVjCDpAi4x4k7KltyCb46QAF9TCcIaUOUBI0M9HJfW1jIA
         sk0TD6BLQ9OHD1jPEFGgi3BLC826FMl9U/v2nFoDhNYBOuI5+tys1Y/Yv0nAAol7vseI
         iUwA==
X-Gm-Message-State: AAQBX9fDj1T6PnL2T+GFVtHaJGXZy8ChOlewJl4Nu/jWDzbweHFbny66
	Ep8KJXokvmzDwl5/G56Hkv3mZPne+mPOblpSp/GKpOLKOT0=
X-Google-Smtp-Source: AK7set8A3KbImjzqPznJ5Tibo3/zC/E831aRwlwsu2qkR0/xQp4cbGMRYCZTFWbreR1VptHr1DKd+CT/hQXlZNJA5M4=
X-Received: by 2002:a05:6a00:1a0b:b0:625:4ff8:3505 with SMTP id
 g11-20020a056a001a0b00b006254ff83505mr18871167pfv.1.1680545090276; Mon, 03
 Apr 2023 11:04:50 -0700 (PDT)
MIME-Version: 1.0
From: Mattis Lind <mattislind@gmail.com>
Date: Mon, 3 Apr 2023 20:04:39 +0200
Message-ID: <CABr82SLAMOUwp+3KkiGbuLLAmzjVVkCZiXc_L358cuRzb=SXJg@mail.gmail.com>
Subject: Intellec 8/80 reading paper tapes?
To: SBC-85 <craig@sbc-85.com>, Sid Jones <jonesthechip@logicmagic.co.uk>, 
	Jon Hales <jonhales@gmail.com>
Content-Type: multipart/alternative; boundary="00000000000022925405f87265bf"
X-Spam-Status: No, score=-0.2
X-Spam-Score: -1
X-Spam-Bar: /
X-Spam-Flag: NO

--00000000000022925405f87265bf
Content-Type: text/plain; charset="UTF-8"

Hello!

It has been a while. I got side tracked with another project. A guy donated
a SWTPC 6809 machine with a terminal and floppy drives. Nice little system,
but not working yet and very dusty when I received it so it required some
attention.

After I got the Intellec 8 running I designed a small current-loop
interface for it and thought a paper tape simulator would be a good idea.
An STM32 controller with a small SD card would allow me to have a bunch of
images to select from. As soon as the Intellec 8 asserts the reader run
signal a menu would be printed on the terminal connected to the paper tape
emulator showing what files there are on the SD card so you could select
one for downloading into the Intellec 8.

Until here everything works fine. But when the reading process starts,  it
stops after 20 characters. I did a try to single step through the code
while receiving characters and then it worked much better. I wasn't able to
finish the entire file, but it got well past 20 characters of input until I
got too tired of pressing the STEP switch repeatedly.

So what could cause this? This all sounds like some kind of timing problem.
But I wanted to be sure before re-designing the software.

I now single stepped through the code while keeping track of it in the
assembly listing I had of the monitor running.

This is the section which is pulsing the Reader Run and reading one byte:

RI:   PUSH H        ;3EB7-E5          <-- ENTRY
      LXI H,IOBYTE  ;3EB8-21 03 00
      MOV A,M       ;3EBB-7E
      ANI 00CH      ;3EBC-E6 0C
      JNZ RI3       ;3EBE-C2 E4 3E
      MVI A,HT      ;3EC1-3E 09
      OUT TTYS      ;3EC3-D3 01      <-- CLEAR READER RUN

RI0:  MVI A,BS      ;3EC5-3E 08
      OUT TTYS      ;3EC7-D3 01      <-- SET READER RUN
      MVI H,0FFH    ;3EC9-26 FF
      ANI 001H      ;3ECB-E6 01      <-- AND A with 01h But isn't A just
08h?
      JZ RI2        ;3ECD-CA DE 3E   <-- Jump on 0. Always take this?
      CALL DELAY    ;3ED0-CD 37 3D   <-- When do we get here?
      CALL DELAY    ;3ED3-CD 37 3D
      DCR H         ;3ED6-25
      JNZ RI0       ;3ED7-C2 C5 3E   <-- It makes no sense looping if we
aren't reading some condition!

RI1:  XRA A         ;3EDA-AF
      STC           ;3EDB-37
      POP H         ;3EDC-E1
      RET           ;3EDD-C9

RI2:  IN TTYD       ;3EDE-DB 00      <-- Get here then and read data
      CMA           ;3EE0-2F
      ORA A         ;3EE1-B7
      POP H         ;3EE2-E1
      RET           ;3EE3-C9         <-- Return to caller.

The routine above is called from this small routine:

RIX:  CALL RI       ;3F12-CD B7 3E
      JC   LER      ;3F15-DA 67 3C  <-- If carry we bail out to 3C67h
      ANI  07FH     ;3F18-E6 7F
      RET           ;3F1A-C9


The code at 3C67 simply prints a '*' and jumps to the START of the monitor
which prints a CRLF and a '.' then it is the command interpreter again.

The IO board has two addresses. 0 and 1

0 is the data buffer
1 is the control / status register.

Status register has bits allocated as follows:

0   DA - DataAvailable
1   OR - OverRun
2   TBMT - TransmitterBuffereMpTy
3   FE   - FramingError
4   PE   - ParityError

Control register has one single bit used:

0   Reader Run

I am not an 8080 assembly specialist. I think I can read it decently but
the code above puzzles me a bit and I think it has to do with why it
doesn't work.

So I ask you 8080 experts out there if you could give some help
understanding what is happening!

BTW. The full disassembly is here:
https://www.retrotechnology.com/restore/mon80_v4.asm
I sent the ROMs and Bill Beech ran it through his disassembler.

There is a delay routine that loops 256 times through two delay routines to
give some delay but since we are single stepping we never get into that one
I guess. But how can the A register have anything other than 08h in it
after the OUT  instruction?

Unless of course the OUT instruction does an implicit input into the A
register after the OUT??
Then it would read the DA flag and it makes much more sense.

But I have not seen any 8080 manual stating that the OUT instruction also
does an IN implicitly.

What am I missing? How should I interpret the assembly code?

If it indeed turns out that the STM32 is slow at times, it is indeed
looping through quite some code when polling the reader run bit and also
reads stuff off the SD-card, then I will probably enable hardware handshake
on the UART and hopefully it will solve it. But understanding if this is
the root cause or not would be helpful.

Any input would be very helpful!

Thanks!

/Mattis

--00000000000022925405f87265bf
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello!<div><br></div><div>It has been a while. I got side =
tracked with another project. A guy donated a SWTPC 6809 machine with a ter=
minal and floppy drives. Nice little system, but not working yet and very d=
usty when I received it so it required some attention.</div><div><br></div>=
<div>After I got the Intellec=C2=A08 running I designed a small current-loo=
p interface for it and thought a paper tape simulator would be a good idea.=
 An STM32 controller with a small SD card would allow me to have a bunch=C2=
=A0of images to select from. As soon as the Intellec=C2=A08 asserts the rea=
der run signal a menu would be printed on the terminal connected to the pap=
er tape emulator showing what files there are on the SD card so you could s=
elect one for downloading into the Intellec=C2=A08.</div><div><br></div><di=
v>Until here everything works fine. But when the reading process starts,=C2=
=A0 it stops after 20 characters. I did a try to single step through the co=
de while receiving characters and then it=C2=A0worked much better. I wasn&#=
39;t able to finish the entire file, but it got well past 20 characters of =
input until I got too tired of pressing the STEP switch repeatedly.</div><d=
iv><br></div><div>So what could cause this? This all sounds like some kind =
of timing problem. But I wanted to be sure before re-designing the software=
.</div><div><br></div><div>I now single stepped through the code while keep=
ing track of it in the assembly listing I had of the monitor running.</div>=
<div><br></div><div>This is the section which is pulsing the Reader Run and=
 reading one byte:</div><div><br></div><div><font face=3D"monospace">RI:=C2=
=A0 =C2=A0PUSH	H=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;3EB7-E5=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 &lt;-- ENTRY<br>=C2=A0 =C2=A0 =C2=A0 LXI	H,IOBYTE=C2=A0 ;3EB8=
-21 03 00<br>=C2=A0 =C2=A0 =C2=A0 MOV	A,M=C2=A0 =C2=A0 =C2=A0 =C2=A0;3EBB-7=
E<br>=C2=A0 =C2=A0 =C2=A0 ANI	00CH=C2=A0 =C2=A0 =C2=A0 ;3EBC-E6 0C<br>=C2=
=A0 =C2=A0 =C2=A0 JNZ	RI3=C2=A0 =C2=A0 =C2=A0 =C2=A0;3EBE-C2 E4 3E<br>=C2=
=A0 =C2=A0 =C2=A0 MVI	A,HT=C2=A0 =C2=A0 =C2=A0 ;3EC1-3E 09<br>=C2=A0 =C2=A0=
 =C2=A0 OUT	TTYS=C2=A0 =C2=A0 =C2=A0 ;3EC3-D3 01=C2=A0 =C2=A0 =C2=A0 &lt;--=
 CLEAR READER RUN<br><br>RI0:=C2=A0 MVI	A,BS=C2=A0 =C2=A0 =C2=A0 ;3EC5-3E 0=
8<br>=C2=A0 =C2=A0 =C2=A0 OUT	TTYS=C2=A0 =C2=A0 =C2=A0 ;3EC7-D3 01=C2=A0 =
=C2=A0 =C2=A0 &lt;-- SET READER RUN<br>=C2=A0 =C2=A0 =C2=A0 MVI	H,0FFH=C2=
=A0 =C2=A0 ;3EC9-26 FF<br>=C2=A0 =C2=A0 =C2=A0 ANI	001H=C2=A0 =C2=A0 =C2=A0=
 ;3ECB-E6 01=C2=A0 =C2=A0 =C2=A0 &lt;-- AND A with 01h But isn&#39;t A just=
 08h?<br>=C2=A0 =C2=A0 =C2=A0 JZ	RI2=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;3ECD-CA DE=
 3E=C2=A0 =C2=A0&lt;-- Jump on 0. Always take this?<br>=C2=A0 =C2=A0 =C2=A0=
 CALL	DELAY=C2=A0 =C2=A0 ;3ED0-CD 37 3D=C2=A0 =C2=A0&lt;-- When do we get h=
ere?<br>=C2=A0 =C2=A0 =C2=A0 CALL	DELAY=C2=A0 =C2=A0 ;3ED3-CD 37 3D<br>=C2=
=A0 =C2=A0 =C2=A0 DCR	H=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3ED6-25<br>=C2=A0=
 =C2=A0 =C2=A0 JNZ	RI0=C2=A0 =C2=A0 =C2=A0 =C2=A0;3ED7-C2 C5 3E=C2=A0 =C2=
=A0&lt;-- It makes no sense looping if we aren&#39;t reading some condition=
!<br><br>RI1:=C2=A0 XRA	A=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EDA-AF<br>=C2=
=A0 =C2=A0 =C2=A0 STC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EDB-37<br>=
=C2=A0 =C2=A0 =C2=A0 POP	H=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EDC-E1<br>=C2=
=A0 =C2=A0 =C2=A0 RET=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EDD-C9<br><=
br>RI2:=C2=A0 IN	TTYD=C2=A0 =C2=A0 =C2=A0 =C2=A0;3EDE-DB 00=C2=A0 =C2=A0 =
=C2=A0 &lt;-- Get here then and read data<br>=C2=A0 =C2=A0 =C2=A0 CMA=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EE0-2F<br>=C2=A0 =C2=A0 =C2=A0 ORA	A=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EE1-B7<br>=C2=A0 =C2=A0 =C2=A0 POP	H=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EE2-E1<br>=C2=A0 =C2=A0 =C2=A0 RET=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3EE3-C9=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0&lt;-- Return to caller.</font><br></div><div><br></div><div>The routine=
=C2=A0above is called from this small routine:</div><div><br></div><font fa=
ce=3D"monospace">RIX:=C2=A0 CALL RI=C2=A0 =C2=A0 =C2=A0 =C2=A0;3F12-CD B7 3=
E<br>=C2=A0 =C2=A0 =C2=A0 JC=C2=A0 =C2=A0LER=C2=A0 =C2=A0 =C2=A0 ;3F15-DA 6=
7 3C=C2=A0 &lt;-- If carry we bail out to 3C67h<br>=C2=A0 =C2=A0 =C2=A0 ANI=
=C2=A0 07FH=C2=A0 =C2=A0 =C2=A0;3F18-E6 7F<br></font><div><font face=3D"mon=
ospace">=C2=A0 =C2=A0 =C2=A0 RET=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;3=
F1A-C9=C2=A0</font></div><div><br></div><div><font face=3D"monospace"><br><=
/font></div><div><font face=3D"monospace">The code at 3C67 simply prints a =
&#39;*&#39; and jumps to the START of the monitor which prints a CRLF and a=
 &#39;.&#39; then it is the command interpreter again.</font></div><div><fo=
nt face=3D"monospace"><br></font></div><div><font face=3D"monospace">The IO=
 board has two addresses. 0 and 1</font></div><div><font face=3D"monospace"=
><br></font></div><div><font face=3D"monospace">0 is the data buffer=C2=A0<=
/font></div><div><font face=3D"monospace">1 is the control / status registe=
r.</font></div><div><font face=3D"monospace"><br></font></div><div><font fa=
ce=3D"monospace">Status register has bits allocated as follows:</font></div=
><div><font face=3D"monospace"><br></font></div><div><font face=3D"monospac=
e">0=C2=A0 =C2=A0DA - DataAvailable=C2=A0</font></div><div><font face=3D"mo=
nospace">1=C2=A0 =C2=A0OR - OverRun</font></div><div><font face=3D"monospac=
e">2=C2=A0 =C2=A0TBMT - TransmitterBuffereMpTy</font></div><div><font face=
=3D"monospace">3=C2=A0 =C2=A0FE=C2=A0 =C2=A0- FramingError</font></div><div=
><font face=3D"monospace">4=C2=A0 =C2=A0PE=C2=A0 =C2=A0- ParityError</font>=
</div><div><font face=3D"monospace"><br></font></div><div><font face=3D"mon=
ospace">Control register has one single bit used:</font></div><div><font fa=
ce=3D"monospace"><br></font></div><div><font face=3D"monospace">0=C2=A0 =C2=
=A0Reader Run</font></div><div><font face=3D"monospace"><br></font></div><d=
iv><font face=3D"arial, sans-serif">I am not an 8080 assembly specialist. I=
 think I can read it decently but the code above puzzles me a bit and I thi=
nk it has to do with why it doesn&#39;t work.</font></div><div><font face=
=3D"arial, sans-serif"><br></font></div><div><font face=3D"arial, sans-seri=
f">So I ask you 8080 experts out there if you could give some help understa=
nding what is happening!</font></div><div><font face=3D"arial, sans-serif">=
<br></font></div><div><font face=3D"arial, sans-serif">BTW. The full disass=
embly=C2=A0is here:=C2=A0</font><a href=3D"https://www.retrotechnology.com/=
restore/mon80_v4.asm">https://www.retrotechnology.com/restore/mon80_v4.asm<=
/a></div><div>I sent the ROMs and Bill Beech ran it through his disassemble=
r.</div><div><br></div><div>There is a delay routine that loops 256 times t=
hrough two delay routines to give some delay but since we are single steppi=
ng=C2=A0we never get into that one I guess. But how can the A register have=
 anything other than 08h in it after the OUT=C2=A0 instruction?</div><div><=
br></div><div>Unless of course the OUT instruction does an implicit input i=
nto the A register after the OUT??</div><div>Then it would read the DA flag=
 and it makes much more sense.</div><div><br></div><div>But I have not seen=
 any 8080 manual stating that the OUT instruction also does an IN implicitl=
y.=C2=A0</div><div><br></div><div>What am I missing? How should I interpret=
 the assembly code?</div><div><br></div><div>If it indeed turns out that th=
e STM32 is slow at times, it is indeed looping through quite some code when=
 polling the reader run bit and also reads stuff off the SD-card, then I wi=
ll probably enable hardware handshake on the UART and hopefully it will sol=
ve it. But understanding if this is the root cause or not would be helpful.=
</div><div><br></div><div>Any input would be very helpful!</div><div><br></=
div><div>Thanks!</div><div><br></div><div>/Mattis</div><div><br></div><div>=
<br></div></div>

--00000000000022925405f87265bf--
