-
Notifications
You must be signed in to change notification settings - Fork 0
/
char_dump.py
executable file
·82 lines (67 loc) · 2.47 KB
/
char_dump.py
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
76
77
78
79
80
81
82
#!/usr/bin/python
# minimal firmware the boneless, dump the char set and blink a light.
from boneless.arch.opcode import Instr
from boneless.arch.opcode import *
from spork.firmware.base import *
from spork.lib.uartIO import UART
from spork.firmware.firmware import Firmware
from spork.logger import logger
log = logger(__name__)
class CharSplash(Firmware):
def setup(self):
"registers in the bottom Window"
self.w.req(["temp", "counter", "wait", "dur"])
def prelude(self):
return [MOVI(self.w.dur, 0xFFFF)]
def instr(self):
"Locals and the attached subroutine in the main loop"
" grab the named register window for local use"
w = self.w
" local reference to this list of named registers for the peripherals"
reg = self.reg
" make a set of local labels that will not collide "
ll = LocalLabels()
" create a instance of ASM subroutines , they only get included if they are used"
uart = UART()
return [
Rem("there is a main loop around these instrutions"),
Rem("start at space, ignore control char"),
MOVI(w.counter, 32),
Rem("enable and , turn on the led"),
MOVI(w.temp, 1),
STXA(w.temp, reg.statusled.en),
ll("loop"),
[
Rem("write the char to the uart"),
uart.write(w.counter),
Rem("invert the led"),
XORI(w.temp, w.temp, 0xFFFF),
STXA(w.temp, reg.statusled.led),
Rem("Delay loop"),
MOV(w.wait, w.dur),
ll("wait"),
SUBI(w.wait, w.wait, 1),
CMPI(w.wait, 0),
BNE(ll.wait),
Rem("End delay loop"),
Rem("Increment the char counter"),
ADDI(w.counter, w.counter, 1),
Rem("are at the end of the printable chars?"),
CMPI(w.counter, 125),
BNE(ll.loop),
SUBI(w.dur, w.dur, 0x0FFF),
CMPI(w.dur, 0x0000),
BNE(ll.skip),
MOVI(w.dur, 0xFFFF),
ll("skip"),
uart.writeHex(w.dur),
],
Rem("and around again, Firmware has builtin main loop"),
]
firmware = CharSplash
if __name__ == "__main__":
from spork.upload import Uploader
import fwtest
spork = fwtest.build(firmware)
up = Uploader()
up.upload(spork)