4 ; TODO: will the assembler be able to evaluate these expressions?
5 .define UART_BASE, 0x1000
6 .define UART_STATUS, (UART_BASE+0x4)
7 .define UART_RECV, (UART_BASE+0x8)
8 .define UART_TRANS, (UART_BASE+0xC)
9 .define UART_BAUD, (UART_BAUD+0x10)
11 .define UART_TRANS_EMPTY, 0
12 .define UART_RECV_NEW, 1
14 .define TIMEOUT_START, 0x13371337
15 .define DEFAULT_PROG_START, 0x200
16 .define STACKSTART, 0x500 ; FIXME
20 ldil r15, STACKSTART@lo
21 ldih r15, STACKSTART@hi
24 ldil r3, TIMEOUT_START@lo
25 ldih r3, TIMEOUT_START@hi
28 ldil r3, UART_STATUS@lo
29 ldih r3, UART_STATUS@hi
31 andi r3, r3, 1 << UART_RECV_NEW
32 branchzs+ next; branch if zero
35 ; we received the enter bootrom sign
41 branchnz+ timeout_loop
43 ; call to default entry point
44 ldil r0, DEFAULT_PROG_START@lo
45 ldih r0, DEFAULT_PROG_START@hi
50 ldil r3, UART_STATUS@lo
51 ldih r3, UART_STATUS@hi
53 andi r3, r3, 1 << UART_TRANS_EMPTY
54 branchzs+ send_byte ; branch if zero
55 ldil r3, UART_TRANS@lo
56 ldih r3, UART_TRANS@hi
62 ; TODO: loop? (less codesize...)
75 ldil r3, UART_STATUS@lo
76 ldih r3, UART_STATUS@hi
78 andi r3, r3, 1 << UART_RECV_NEW
79 branchzs+ send_byte ; branch if zero
125 ; cmpi r0, 0x48 ; 'H'
135 call recv_word ; receive addr
137 call recv_word ; receive instr
144 call recv_word ; receive addr
153 call recv_word ; receive addr
155 call recv_word ; receive data
162 call recv_word ; receive addr
174 ; 102 instr. please update after modification