summaryrefslogtreecommitdiff
path: root/assembly
diff options
context:
space:
mode:
Diffstat (limited to 'assembly')
-rw-r--r--assembly/meseconsio/Makefile24
-rw-r--r--assembly/meseconsio/meseconsio.S30
-rwxr-xr-xassembly/meseconsio/meseconsio.elfbin0 -> 5348 bytes
-rw-r--r--assembly/meseconsio/meseconsio.hex7
-rw-r--r--assembly/meseconsio/meseconsio.obin0 -> 1192 bytes
l---------assembly/meseconsio/rvcontroller.ld1
6 files changed, 62 insertions, 0 deletions
diff --git a/assembly/meseconsio/Makefile b/assembly/meseconsio/Makefile
new file mode 100644
index 0000000..786418a
--- /dev/null
+++ b/assembly/meseconsio/Makefile
@@ -0,0 +1,24 @@
+MARCH ?= rv32imacbzicntr_zicond_zicsr_zifencei_zihintpause_zilsd_zclsd_zabha_zacas_zawrs_zbkb_zbkx_zcb_zcmp_zcmt
+
+.PHONY: all dump load clean
+
+all: meseconsio.hex
+
+meseconsio.o: meseconsio.S
+ riscv32-none-elf-as -I../rvcontroller-libraries -march=${MARCH} -o meseconsio.o meseconsio.S
+
+meseconsio.elf: meseconsio.o
+ riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o meseconsio.elf meseconsio.o
+
+dump: meseconsio.elf
+ riscv32-none-elf-objdump -d meseconsio.elf
+
+meseconsio.hex: meseconsio.elf
+ riscv32-none-elf-objcopy -O ihex meseconsio.elf meseconsio.hex
+
+load: meseconsio.hex
+ bash -c "wl-copy < meseconsio.hex"
+
+clean:
+ rm -f meseconsio.bin meseconsio.elf meseconsio.o
+
diff --git a/assembly/meseconsio/meseconsio.S b/assembly/meseconsio/meseconsio.S
new file mode 100644
index 0000000..f2a441f
--- /dev/null
+++ b/assembly/meseconsio/meseconsio.S
@@ -0,0 +1,30 @@
+ li s0,0xffff0000
+ csrw 0x801,s0 # Set MMIO base address
+
+ li t0,0x7 # Pin D input, others output
+ sb t0,0(s0) # Write to mesecons I/O direction register
+
+start: lr.w x0,0(s0) # Establish a reservation set on the mesecons I/O region
+ wrs.nto # Wait for it to become invalid
+ lb t0,1(s0) # Read the mesecons I/O data
+ andi t1,t0,0x8 # Is pin D on?
+ beqz t1,start # If not, go wait again
+
+ li t0,1 # only A on
+ sb t0,1(s0)
+ pause
+ pause
+ pause
+ li t0,2 # only B on
+ sb t0,1(s0)
+ pause
+ pause
+ pause
+ li t0,4 # only C on
+ sb t0,1(s0)
+ pause
+ pause
+ pause
+ li t0,0 # all off
+ sb t0,1(s0)
+ j start
diff --git a/assembly/meseconsio/meseconsio.elf b/assembly/meseconsio/meseconsio.elf
new file mode 100755
index 0000000..09468fe
--- /dev/null
+++ b/assembly/meseconsio/meseconsio.elf
Binary files differ
diff --git a/assembly/meseconsio/meseconsio.hex b/assembly/meseconsio/meseconsio.hex
new file mode 100644
index 0000000..5feb581
--- /dev/null
+++ b/assembly/meseconsio/meseconsio.hex
@@ -0,0 +1,7 @@
+:100000004174731014809D42230054002F2004106B
+:100010007300D0008302140013F38200E30803FE90
+:100020008542A30054000F0000010F0000010F00E3
+:1000300000018942A30054000F0000010F000001DD
+:100040000F0000019142A30054000F0000010F00B7
+:0E00500000010F0000018142A300540045BFD3
+:00000001FF
diff --git a/assembly/meseconsio/meseconsio.o b/assembly/meseconsio/meseconsio.o
new file mode 100644
index 0000000..33ce2df
--- /dev/null
+++ b/assembly/meseconsio/meseconsio.o
Binary files differ
diff --git a/assembly/meseconsio/rvcontroller.ld b/assembly/meseconsio/rvcontroller.ld
new file mode 120000
index 0000000..bc01402
--- /dev/null
+++ b/assembly/meseconsio/rvcontroller.ld
@@ -0,0 +1 @@
+../../rvcontroller.ld \ No newline at end of file