8085 Assembler, adding another menu choice disables char input from sid (Resolved)?

Thread Starter

keiichicom

Joined Apr 26, 2022
76
Hi,

This program works fine as shown in the TeraTerm picture below the code.

Working Code

Code:
# ORG 00A3H
# DB DATA:20H,0DH,0AH,57H,65H,6CH,63H,6FH,6DH,65H,20H,74H,6FH,20H,74H,68H,65H,20H,38H,30H,38H,35H,20H,4DH,6FH,6EH,69H,74H,6FH,72H,0DH,0AH,50H,72H,65H,73H,73H,20H,68H,20H,66H,6FH,72H,20H,68H,65H,6CH,70H,0DH,0AH,3EH

# ORG 00D6H
# DB DATA:0DH,0AH,38H,30H, 38H, 35H, 20H, 4DH, 6FH, 6EH, 69H, 74H, 6FH, 72H, 20H, 48H, 65H, 6CH, 70H, 0DH, 0AH,4CH, 65H, 67H, 65H, 6EH, 64H, 3AH, 20H, 78H, 78H, 78H, 78H, 68H, 20H, 73H, 74H, 61H, 72H, 74H, 69H, 6EH, 67H, 20H, 6DH, 65H, 6DH, 6FH, 72H, 79H, 20H, 61H, 64H, 64H, 72H, 65H, 73H, 73H, 2CH, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 2EH, 2EH, 2EH, 20H, 64H, 61H, 74H, 61H, 0DH, 0AH,0DH,0AH,77H,20H,78H,78H,78H,78H,68H, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 20H, 2EH, 2EH, 2EH, 20H, 77H, 72H, 69H, 74H, 65H, 20H, 64H, 61H, 74H, 61H, 20H, 74H, 6FH, 20H, 52H, 4FH, 4DH, 0DH, 0AH,72H, 20H, 78H, 78H, 78H, 78H, 68H, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 20H, 2EH, 2EH, 2EH, 20H, 72H, 65H, 61H, 64H, 20H, 64H, 61H, 74H, 61H, 20H, 66H, 72H, 6FH, 6DH, 20H, 52H, 4FH, 4DH, 0DH, 0AH,65H, 20H,78H, 78H, 78H, 78h,68H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 65H, 78H, 65H, 63H, 75H, 74H, 65H, 73H, 20H, 74H, 68H, 65H, 20H, 70H, 72H, 6FH, 67H, 72H, 61H, 6DH, 20H, 61H, 74H, 20H, 78H, 78H, 78H, 78H, 68H, 0DH, 0AH,73H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 28H, 72H,65H,73H,65H,74H,29H, 20H, 65H, 78H, 65H, 63H, 75H, 74H, 65H, 73H, 20H, 74H, 68H, 65H, 20H, 70H, 72H, 6FH, 67H, 72H, 61H, 6DH, 20H, 61H, 74H, 20H, 30H, 30H, 30H, 30H, 68H, 0DH,0AH,64H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,44H,65H,6DH,6FH,3AH,20H,41H,53H,43H,49H,49H,20H,43H,61H,74H,20H,41H,72H,74H,0AH,62H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,45H,6EH,74H,65H,72H,20H,61H,20H,42H,41H,53H,49H,43H,20H,53H,68H,65H,6CH,6CH,0AH,61H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,45H,6EH,74H,65H,72H,20H,61H,6EH,20H,41H,73H,73H,65H,6DH,62H,6CH,65H,72H,20H,53H,68H,65H,6CH,6CH,0DH,0AH,3EH


# ORG 0278H
# DB DATA:0DH,0AH,7CH,5CH,2DH,2DH,2DH,2FH,7CH,0DH,7CH,20,6FH,5F,6FH,20,7CH,0DH,20,5C,5F,5E,5F,2FH,0DH,0AH,3EH

# ORG 0000H
LXI SP,7FFFH
INITIALIZE: MVI D,00H
MVI E,33H
LXI H,00A3H

START: PUSH H
MOV C,M
CALL COUT
POP H
INX H
DCX D
PUSH PSW
MOV A, D    ; MOVE THE CONTENT OF REGISTER D INTO THE ACCUMULATOR A
ORA E       ; LOGICAL OR OPERATION WITH REGISTER E

JNZ START
POP PSW
MENU: CALL CIN
   CPI 68H                 
   JNZ DEMO
   CALL HELPPARM
   JZ START
   DEMO: CPI 64H
   JNZ RESET
   CALL DEMOPARM
   JZ START
   RESET: CPI 73H
  JNZ MENU
  JMP INITIALIZE
HLT

COUT:
   DI
   MVI B,0B    ; NUMBER OF OUTPUT BITS
   XRA A    ; CLEAR CARRY FOR START BIT

   CO1: MVI A,80    ; SET THE SDE FLAG
   RAR    ; SHIFT CARRY INTO SOD FLAG
   CMC    ; AND INVERT CARRY. WHY? (SERIAL IS INVERTED?)
   SIM    ; OUTPUT DATA BIT
   LXI H,0112    ; LOAD THE TIME DELAY FOR ONE BIT WIDTH

   CO2: DCR L    ; WAIT FOR BIT TIME
   JNZ CO2
   DCR H
   JNZ CO2
   STC    ; SHIFT IN STOP BIT(S)
   MOV A,C    ; GET CHAR TO SEND
   RAR    ; LSB INTO CARRY
   MOV C,A    ; STORE ROTATED DATA
   DCR B
   JNZ CO1    ; SEND NEXT BIT
   EI
   LXI H,3FFF    ; WAIT A WHILE BEFORE SENDING THE CHARACTER AGAIN

   CHILL: DCR L
   JNZ CHILL
   DCR H
   JNZ CHILL
RET

CIN:
   DI
   PUSH B
   MVI B,09        ; LOOP COUNT IS NUMBER OF BITS TO BE READ MINUS ONE
   CI1: RIM                     ; DOES NOT INCLUDE STOP BITS
   ORA A
   JM CI1
   LXI H,0109H      ; DELAY A HALF BIT TIME TO GET TO THE MIDDLE OF THE START BIT
   CI2: DCR L
   JNZ CI2
   DCR H
   JNZ CI2
   CI3: LXI H,0112H       ; DELAY TO THE MIDDLE OF THE NEXT DATA BIT
   CI4: DCR L
   JNZ CI4
   DCR H
   JNZ CI4

   RIM                     ; READ THE NEXT DATA BIT
   RAL                     ; SHIFT THE DATA BIT INTO THE CARRY FLAG
   DCR B               ; EXIT IF ALL OF THE BITS HAVE BEEN READ
   JZ CI5
   MOV A,C             ; CHARACTER IN PROGRESS INTO A
   RAR                     ; SHIFT THE DATA BIT FROM CARRY INTO THE MSB
   MOV C,A             ; STORE THE CHARACTER BACK INTO C
   JMP CI3             ; GET THE NEXT BIT

   CI5: MOV A,C             ; RETURN THE CHARACTER IN A
   POP B
   EI
RET

HELPPARM:
   LXI H,00D6H
   MVI D, 01H
   MVI E, A2H
RET

DEMOPARM:
   LXI H,0278H
   MVI D, 00H
   MVI E, 1BH
RET
Teraterm Screen For Working Code

teraterm.PNG

But adding handling for an extra menu choice, in this case b for basic, code is below, seems to stop all input although the welcome text is displayed. I did a file compare with the two assembly code listings but the differences are all expected.



Please assist if you can.

Broken code:

Code:
# ORG 00B6H
# DB DATA:20H,0DH,0AH,57H,65H,6CH,63H,6FH,6DH,65H,20H,74H,6FH,20H,74H,68H,65H,20H,38H,30H,38H,35H,20H,4DH,6FH,6EH,69H,74H,6FH,72H,0DH,0AH,50H,72H,65H,73H,73H,20H,68H,20H,66H,6FH,72H,20H,68H,65H,6CH,70H,0DH,0AH,3EH

# ORG 00E9H
# DB DATA:0DH,0AH,38H,30H, 38H, 35H, 20H, 4DH, 6FH, 6EH, 69H, 74H, 6FH, 72H, 20H, 48H, 65H, 6CH, 70H, 0DH, 0AH,4CH, 65H, 67H, 65H, 6EH, 64H, 3AH, 20H, 78H, 78H, 78H, 78H, 68H, 20H, 73H, 74H, 61H, 72H, 74H, 69H, 6EH, 67H, 20H, 6DH, 65H, 6DH, 6FH, 72H, 79H, 20H, 61H, 64H, 64H, 72H, 65H, 73H, 73H, 2CH, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 2EH, 2EH, 2EH, 20H, 64H, 61H, 74H, 61H, 0DH, 0AH,0DH,0AH,77H,20H,78H,78H,78H,78H,68H, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 20H, 2EH, 2EH, 2EH, 20H, 77H, 72H, 69H, 74H, 65H, 20H, 64H, 61H, 74H, 61H, 20H, 74H, 6FH, 20H, 52H, 4FH, 4DH, 0DH, 0AH,72H, 20H, 78H, 78H, 78H, 78H, 68H, 20H, 78H, 78H, 68H, 2CH, 20H, 79H, 79H, 68H, 2CH, 20H, 7AH, 7AH, 68H, 2CH, 20H, 2EH, 2EH, 2EH, 20H, 72H, 65H, 61H, 64H, 20H, 64H, 61H, 74H, 61H, 20H, 66H, 72H, 6FH, 6DH, 20H, 52H, 4FH, 4DH, 0DH, 0AH,65H, 20H,78H, 78H, 78H, 78h,68H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 65H, 78H, 65H, 63H, 75H, 74H, 65H, 73H, 20H, 74H, 68H, 65H, 20H, 70H, 72H, 6FH, 67H, 72H, 61H, 6DH, 20H, 61H, 74H, 20H, 78H, 78H, 78H, 78H, 68H, 0DH, 0AH,73H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 20H, 28H, 72H,65H,73H,65H,74H,29H, 20H, 65H, 78H, 65H, 63H, 75H, 74H, 65H, 73H, 20H, 74H, 68H, 65H, 20H, 70H, 72H, 6FH, 67H, 72H, 61H, 6DH, 20H, 61H, 74H, 20H, 30H, 30H, 30H, 30H, 68H, 0DH,0AH,64H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,44H,65H,6DH,6FH,3AH,20H,41H,53H,43H,49H,49H,20H,43H,61H,74H,20H,41H,72H,74H,0AH,62H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,45H,6EH,74H,65H,72H,20H,61H,20H,42H,41H,53H,49H,43H,20H,53H,68H,65H,6CH,6CH,0AH,61H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,45H,6EH,74H,65H,72H,20H,61H,6EH,20H,41H,73H,73H,65H,6DH,62H,6CH,65H,72H,20H,53H,68H,65H,6CH,6CH,0DH,0AH,3EH


# ORG 028BH
# DB DATA:0DH,0AH,7CH,5CH,2DH,2DH,2DH,2FH,7CH,0DH,7CH,20,6FH,5F,6FH,20,7CH,0DH,20,5C,5F,5E,5F,2FH,0DH,0AH,3EH

# ORG 02A6H
# DB DATA:0DH,0AH,57H,65H,6CH,63H,6FH,6DH,65H,20H,74H,6FH,20H,38H,30H,38H,35H,20H,42H,41H,53H,49H,43H,ODH,OAH,62H,3EH

# ORG 0000H
LXI SP,7FFFH
INITIALIZE: MVI D,00H
MVI E,33H
LXI H,00B6H

START: PUSH H
MOV C,M
CALL COUT
POP H
INX H
DCX D
PUSH PSW
MOV A, D    ; MOVE THE CONTENT OF REGISTER D INTO THE ACCUMULATOR A
ORA E       ; LOGICAL OR OPERATION WITH REGISTER E

JNZ START
POP PSW
MENU: CALL CIN
   CPI 68H                  
   JNZ DEMO
   CALL HELPPARM
   JZ START
   DEMO: CPI 64H
   JNZ BASIC
   CALL DEMOPARM
   JZ START
   BASIC: CPI 62H
   JNZ RESET
   CALL BASICPARM
   JZ START
   RESET: CPI 73H
  JNZ MENU
  JMP INITIALIZE
HLT

COUT:
   DI
   MVI B,0B    ; NUMBER OF OUTPUT BITS
   XRA A    ; CLEAR CARRY FOR START BIT

   CO1: MVI A,80    ; SET THE SDE FLAG
   RAR    ; SHIFT CARRY INTO SOD FLAG
   CMC    ; AND INVERT CARRY. WHY? (SERIAL IS INVERTED?)
   SIM    ; OUTPUT DATA BIT
   LXI H,0112    ; LOAD THE TIME DELAY FOR ONE BIT WIDTH

   CO2: DCR L    ; WAIT FOR BIT TIME
   JNZ CO2
   DCR H
   JNZ CO2
   STC    ; SHIFT IN STOP BIT(S)
   MOV A,C    ; GET CHAR TO SEND
   RAR    ; LSB INTO CARRY
   MOV C,A    ; STORE ROTATED DATA
   DCR B
   JNZ CO1    ; SEND NEXT BIT
   EI
   LXI H,3FFF    ; WAIT A WHILE BEFORE SENDING THE CHARACTER AGAIN

   CHILL: DCR L
   JNZ CHILL
   DCR H
   JNZ CHILL
RET

CIN:
   DI
   PUSH B
   MVI B,09        ; LOOP COUNT IS NUMBER OF BITS TO BE READ MINUS ONE
   CI1: RIM                     ; DOES NOT INCLUDE STOP BITS
   ORA A
   JM CI1
   LXI H,0109H      ; DELAY A HALF BIT TIME TO GET TO THE MIDDLE OF THE START BIT
   CI2: DCR L
   JNZ CI2
   DCR H
   JNZ CI2
   CI3: LXI H,0112H       ; DELAY TO THE MIDDLE OF THE NEXT DATA BIT
   CI4: DCR L
   JNZ CI4
   DCR H
   JNZ CI4

   RIM                     ; READ THE NEXT DATA BIT
   RAL                     ; SHIFT THE DATA BIT INTO THE CARRY FLAG
   DCR B               ; EXIT IF ALL OF THE BITS HAVE BEEN READ
   JZ CI5
   MOV A,C             ; CHARACTER IN PROGRESS INTO A
   RAR                     ; SHIFT THE DATA BIT FROM CARRY INTO THE MSB
   MOV C,A             ; STORE THE CHARACTER BACK INTO C
   JMP CI3             ; GET THE NEXT BIT

   CI5: MOV A,C             ; RETURN THE CHARACTER IN A
   POP B
   EI
RET

HELPPARM:
   LXI H,00E9H
   MVI D, 01H
   MVI E, A2H
RET

DEMOPARM:
   LXI H,028BH
   MVI D, 00H
   MVI E, 1BH
RET

BASICPARM:
   LXI H,02A6H
   MVI D, 00H
   MVI E, 1DH
RET
-Kei
 
Last edited:

Thread Starter

keiichicom

Joined Apr 26, 2022
76
Update: It works now, since I re-built my computer. Not sure what was the problem. The only difference is I put a transistor circuit LED driver at the SOD pin and I haven't put back the switch debounce flip flop for the hardware reset circuit yet.

TeraTerm Output

terzterm2.PNG

-Kei
 

Attachments

Top