Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Evgeny Adamenkov
Published © MIT

A Simple Way to Connect a Small Display to an 8080 Computer

Use a debug serial monitor as a display for the 8080-based computer UT-88 (or any 8080 kit), with less than 80 bytes of "library" code.

BeginnerFull instructions provided1 hour125
A Simple Way to Connect a Small Display to an 8080 Computer

Things used in this project

Hardware components

UT-88 Soviet DIY educational computer
or any 8080/8085/Z80 kit
×1
Mini 0.96 OLED Breadboard Debugging Serial Monitor
×1
14-pin DIP Clip
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
optional
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Code

Example

Plain text
Bit-banging to imitate serial transmission at the speed of 9,600 baud.
address opcode(s)   instruction          comment
-----------------------------------------------------
C000    21 0C C0    LXI     H,VOTTAKVOT  ; address of the string "Vot tak vot!!!" below
C003    CD 00 C2    CALL    PUTS         ; call subroutine to display string on the display
C006    C7          RST     0            ; end of program

CLEAR_SCREEN:
C007    AF          XRA     A            ; zeroing the accumulator
C008    CD 11 C2    CALL    PUTCHAR      ; sending zero byte to clear the display screen
C00B    C9          RET                  ; we could have used JMP instead of CALL followed by RET 

VOTTAKVOT:                               ; string to print on the screen
C00C    56 6F 74 20 DB      'Vot '
C010    74 61 6B 20 DB      'tak '
C014    76 6F 74    DB      'vot'
C017    21 00       DB      '!', 0       ; C-style, i.e., should end with a null byte

PUTS:                                    ; subroutine to display string on display
C200    E5          PUSH    H            ; polite subroutine - saves all used registers
C201    F5          PUSH    PSW
    PUTS_2:
C202    7E          MOV     A,M          ; read string character
C203    B7          ORA     A            ; if zero - end of subroutine
C204    CA 0E C2    JZ      PUTS_3
C207    CD 11 C2    CALL    PUTCHAR      ; otherwise - call subroutine to print a character on the screen
C20A    23          INX     H            ; move to the next string character
C20B    C3 02 C2    JMP     PUTS_2
    PUTS_3:
C20E    F1          POP     PSW
C20F    E1          POP     H
C210    C9          RET

PUTCHAR:                                 ; subroutine to display a character on display
C211    C5          PUSH    B
C212    E5          PUSH    H
C213    F5          PUSH    PSW
                                         ; we need to send a sequence of 11 bits
                                         ; 1, 0, D0, D1, D2, D3, D4, D5, D6, D7, 1
C214    21 42 C2    LXI     H,CHAR_BITS+2; aiming for the third bit (the first and second are always 1 and 0)
C217    0E 08       MVI     C,8          ; the 8 bits of the accumulator are mapped to 8 bytes of the sequence
    PUTCHAR_2:
C219    0F          RRC                  ; shift the least significant bit into the Carry flag
C21A    DA 22 C2    JC      PUTCHAR_3    ; if the least significant bit is one, write a byte of 1 into the sequence
C21D    36 00       MVI     M,0          ; otherwise, write a byte of 0
C21F    C3 24 C2    JMP     PUTCHAR_4
    PUTCHAR_3:
C222    36 01       MVI     M,1
    PUTCHAR_4:
C224    23          INX     H            ; move to the next byte of the sequence
C225    0D          DCR     C
C226    C2 19 C2    JNZ     PUTCHAR_2
                    
C229    21 40 C2    LXI     H,CHAR_BITS ; returning to the beginning of the entire sequence
C22C    06 0B       MVI     B,0B        ; out of 11 bytes

C22E    F3          DI                  ; the transmission of the bit sequence should not be interrupted

  PUTCHAR_5:
C22F    7E          MOV     A,M
C230    D3 A1       OUT     A1          ; the least significant bit of the accumulator will reach the RX pin of the display
C232    CD 50 C2    CALL    DELAY       ; hold a pause after sending each bit
C235    23          INX     H
C236    05          DCR     B
C237    C2 2E C2    JNZ     PUTCHAR_5

C23A    FB          EI
C23B    F1          POP     PSW
C23C    E1          POP     H
C23D    C1          POP     B
C23E    C9          RET

  CHAR_BITS:
C240    01 00 00 00 DB      1,0,0,0     ; sequence of 11 bytes to be sent to port A1
C244    00 00 00 00 DB      0,0,0,0
C248    00 00 01    DB      0,0,1

DELAY:                                  ; "pause" subroutine
C250    0E 08       MVI     C,8         ; "magic" number of idle cycles - 8 ("it works on my machine")
  DELAY_2:
C252    0D          DCR     C
C253    C2 52 C2    JNZ     DELAY_2
C256    C9          RET

Credits

Evgeny Adamenkov
5 projects • 0 followers
game AI/ML programmer

Comments