Skip to content

Instantly share code, notes, and snippets.

@vintagechips vintagechips/HELLO05.asm
Last active Jun 20, 2019

Embed
What would you like to do?
HD68P05V07 Software Serial 'HELLO, WORLD'.
* HELLO05
*
* SYSTEM DEFINITIONS
PORTA EQU $00
PORTB EQU $01
PORTC EQU $02
*
PUT EQU PORTC
IN EQU 2
OUT EQU 3
*
* VERIABLES
ORG $0020
RSAVE RMB 1
COUNT RMB 1
*
* MESSAGE
ORG $0080
HELLO FCB 'HELLO, WORLD',$0D,$0A,$00
*
* INITIALIZE
RESET BSET OUT,PUT INITIAL VALUE
BSET OUT,PUT+4 DIRECTION
BCLR IN,PUT+4 DIRECTION
*
* HELLO, WORLD
LDX #0
PUTS LDA HELLO,X
BEQ LOOP
JSR PUTC
INCX
BRA PUTS
*
* ECHO BACK TEST
LOOP JSR GETC
JSR PUTC
BRA LOOP
*
* DELAY
DELAY DECX 4
BNE DELAY 4
RTS 6+7(JSR)
*
* INPUT ROUTINE, 104 CYCLES PER BIT.
GETC BRCLR IN,PUT,* MAKE SURE IT'S HIGH
BRSET IN,PUT,* 10 WAIT FOR START
STX RSAVE 5 (15) SAVE X VALUE
LDX #8 2 (17) 8 BITS TO READ
STX COUNT 5 (23)
LDX #4 2 (25)
BSR DELAY 45 (70)
TST X 6 (76) 0.5 BIT TIME +24
*
INBT LDX #7 2 (26)
BSR DELAY 69 (95)
TST 1,X 7 (102)
NOP 2 (104)
BRCLR IN,PUT,*+3 10 READ
RORA 4 (14) SAVE BIT
DEC COUNT 6 (20)
BNE INBT 4 (24)
*
LDX #13 2
JSR DELAY 117 (119)
LDX RSAVE 6 (125) RESTORE X VALUE
RTS 6 (131)
*
* OUTPUT ROUTINE, 104 CYCLES PER BIT.
PUTC BSET OUT,PUT MAKE SURE IT'S HIGH
STX RSAVE SAVE X VALUE
LDX #10 10 BITS TO SEND
STX COUNT START,8 DATA,STOP
CLC START A ZERO
BRA STAR
*
OUTBT LDX #7 2 (27)
JSR DELAY 69 (96)
NOP 2 (98)
SEC 2 (100) FILL WITH ONES FOR STOP
RORA 4 (104) GET A BIT
*
STAR BCS OU1 4 (4) 1?
BCLR OUT,PUT 7 (11) NO
BRA OBD 4 (15)
OU1 BSET OUT,PUT 7 (11) YES
BRA OBD 4 (15)
OBD DEC COUNT 6 (21)
BNE OUTBT 4 (25) DONE?
LDX RSAVE RESTORE X VALUE
RTS
*
* VECTORS
DUMMY RTI
ORG $0FF8
FDB DUMMY
FDB DUMMY
FDB DUMMY
FDB RESET
*
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.