Assembly examples for Red-V Thing Plus (SiFive FE310-G002)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

50 lines
918 B

#
# macros.s
#
# 2021 flabbergast <flabbergast@drak.xyz>
# Unlicense: https://unlicense.org/
#
# designate some RAM memory to a symbol
.macro ramallot Name, Size
.equ \Name, rampointer
.set rampointer, rampointer + \Size
.endm
# stack: push, pop
.macro push reg
addi sp, sp, -4
sw \reg, 0(sp)
.endm
.macro pop reg
lw \reg, 0(sp)
addi sp, sp, 4
.endm
# insert a sized string
.macro sized_string Text
.byte 8f - 7f # Compute length of string.
7: .ascii "\Text"
.if compressed_isa
8: .balign 2, 0 # Realign
.else
8: .balign 4, 0 # Realign
.endif
.endm
# data stack
# _s11_ used as the data stack pointer!!
.macro pushda reg
addi s11, s11, -4
sw \reg, 0(s11)
.endm
.macro popda reg
lw \reg, 0(s11)
addi s11, s11, 4
.endm
.macro pushdaconst const
push t0 # yep ... should rethink this
li t0, \const # but it should being used very little
pushda t0
pop t0
.endm