-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial.asm
More file actions
68 lines (52 loc) · 1.07 KB
/
Copy pathserial.asm
File metadata and controls
68 lines (52 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;; PROGRAM SERIAL
; this program echoes whatever it receives over USB compile with 'make'
; and flash with 'make flash'
;; DEFINITIONS
; rom chip capacity
ROM_SIZE equ $8000
; stack
STACK_BOTTOM equ $ffff
; serial port
SER_DATA equ $00
SER_FLAG equ $01
SER_BIT_RXE equ 0
SER_BIT_TXF equ 1
org $0000
reset:
di
im 1
ld sp, STACK_BOTTOM
jp init
org $0100
init:
jp main
main:
call receive_byte
call send_byte
jp main
;; SUBROUTINE RECEIVE_BYTE
; waits until receive buffer full flag goes low (data is present)
; and returns the data in register a
receive_byte:
in a, (SER_FLAG)
bit SER_BIT_RXE, a
jp nz, receive_byte
in a, (SER_DATA)
ret
; end of RECEIVE_BYTE
;; SUBROUTINE SEND_BYTE
; waits until the transmit buffer empty flag goes high (in case
; there is a pending transmission) and then writes the
; byte from register a into the transmit buffer
send_byte:
ld b, a
_send_byte_wait:
in a, (SER_FLAG)
bit SER_BIT_TXF, a
jp nz, _send_byte_wait
ld a, b
out (SER_DATA), a
ret
; end of SEND_BYTE
; pad file to eeprom size
ds ROM_SIZE - $