Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SBCF8 hello, world
; SBCF8 hello, world
; dasm f8blink.asm -f3 -of8blink.bin -Lf8blink.lst
UARTD EQU $FF00
UARTC EQU $FF01
PROCESSOR F8
ORG $0000
JMP START
;
; MESSAGE
MESG DC "hello, world"
DC $0D, $0A, 0
;
; S1 -> 8251
PUTCH XDC ;CHANGE MEMORY POINTER
PC1 DCI UARTC ;8251 CONTROL REGISTER
LM ;GET STATUS
NI $01 ;CHECK TX ENABLE
BZ PC1 ;IF NOT, REPEAT
DCI UARTD ;8251 DATA REGISTER
LR A,1 ;SET CHARACTOR
ST ;WRITE
XDC ;CHANGE MEMORY POINTER
POP ;RETURN
;
; 8251 -> S1
GETCH XDC ;CHANGE MEMORY POINTER
GC1 DCI UARTC ;8251 CONTROL REGISTER
LM ;GET STATUS
NI $02 ;CHECK RX DONE
BZ GC1 ;IF NOT, REPEAT
DCI UARTD ;8251 DATA REGISTER
LM ;GET CHARACTOR
LR 1,A ;SET CHARACTOR
XDC ;CHANGE MEMORY POINTER
POP ;RETURN
;
; PUT STRING
PUTS LR K,P ;SAVE RETURN ADDRESS
PS1 LM ;READ CHARACTOR
CI 0 ;CHECK END
BZ PS2 ;IF END, BREAK
LR 1,A ;SET CHARACTOR
PI PUTCH ;CALL PUTCH
JMP PS1 ;REPEAT
PS2 PK ;RETURN BY K
;
; SYSTEM INITIALIZE
START INS 1 ;8251 HARDWARE RESET
NI $7F
OUTS 1
OI $80
OUTS 1
CLR ;ESCAPE
DCI UARTC
ST
DCI UARTC
ST
DCI UARTC
ST
LI $40 ;SOFTWARE RESET
DCI UARTC
ST
LI $4E ;MODE
DCI UARTC
ST
LI $37 ;COMMAND
DCI UARTC
ST
;
; HELLO, WORLD
DCI MESG ;SET MESSAGE TOP ADDRESS
PI PUTS ;CALL PUTS
;
; ECHOBACK
LOOP PI GETCH ;CALL GETCH
PI PUTCH ;CALL PUTCH
JMP LOOP ;REPEAT
;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment