-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmallecho.asm
75 lines (66 loc) · 2.68 KB
/
smallecho.asm
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
69
70
71
72
73
74
75
; Bootloader Console
; Simon Kirkby
; 20190822
; obeygiantrobot@gmail.com
; automatic gizmo headers
;.equ blinky,0
;.equ user_led,1
;.equ tx_status,2
;.equ tx_data,3
;.equ rx_status,4
;.equ rx_data,5
;.equ image,6
;.equ boot,7
base: .window ; todo this macro needs to align to 8 word boundary
win: .window ; named window , this is hand aligned to *8
J init ; jump to init
reboot: ; label for rebooting into
init: ; initialize the program all the registers.
; MOVI R0,base
; STW R0 ; set the register window at zero
; get the tx ready
run: ; main loop
JAL R7,checkrx ; get a char from the serial port
JAL R7,txchar ; write R2 ( holding ) to the serial port
J run
warmboot:
MOVI R0,0 ; set boot image to 0
STXA R0,image ; write to the image external register
MOVI R0,1 ; write one into regiters
STXA R0,boot ; reboot the FPGA into the boot loader
checkrx: ; get a char off the serial port
LDXA R3,rx_status ; load the RX status from the serial port
CMPI R3,1 ; compare the register to 1
BEQ addtopad ; if it is equal to one , add it to the pad
J checkrx
addtopad: ; get the data and acknowledge
LDXA R2,rx_data ; load the RX data from the serial port
LDXA R2,rx_data ; load the RX data from the serial port
MOVI R3,1 ; load 1 into to R3
STXA R3,rx_status ; acknowledge the char in the serial port
waitrdy:
LDXA R3,rx_status
CMPI R3,0
BEQ continue
J waitrdy
continue:
MOVI R3,0 ; load 0 into to R3
STXA R3,rx_status ; acknowledge the char in the serial port
CMPI R2,4 ; check if it is ^D , warmboot
BEQ warmboot
JR R7,0 ; jump to main
txchar: ; put a char into the serial port
STXA R2,tx_data ; put the holding data into the serial port
MOVI R3,1 ; set status to one
STXA R3,tx_status ; write to tx status
MOVI R3,0 ; set the status to zero
STXA R3,tx_status ; acknowledge the write
waitup: ; TODO , this should be a fifo in the serial port
LDXA R3,tx_status ; wait for tx status to go high
CMPI R3,1
BEQ waitup
waitdown:
LDXA R3,tx_status ; wait for the status to go low
CMPI R3,0
BEQ waitdown
JR R7,0