successfully using assembler to generate .hex rather than writing straight machine code
This commit is contained in:
@ -13,8 +13,11 @@ LDFLAGS = -T test.ld
|
||||
%.o: %.S
|
||||
$(AS) $(ASFLAGS) $^ -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
%.elf: %.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
test.hex: test.elf
|
||||
riscv64-linux-gnu-objdump -s $^ | sed -n '/0000/,$$p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' > $@
|
||||
riscv64-linux-gnu-objdump -s $^ | sed -n '/0000/,$$p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
||||
|
28
test/test.S
28
test/test.S
@ -33,4 +33,32 @@ add x29, x0, x0
|
||||
add x30, x0, x0
|
||||
add x31, x0, x0
|
||||
|
||||
# nop required because cpu currently does not detect when something is needed from a later stage of the pipeline.
|
||||
# 5 clocks allows one instruction to finish before the next starts
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi x1, x0, 0x12
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi x2, x0, 0x11
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
add x3, x2, x1
|
||||
loop:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
j loop
|
||||
|
||||
.data
|
||||
|
Reference in New Issue
Block a user