Alignment in linker script
This commit is contained in:
parent
3725cbe58d
commit
005ad4e987
4 changed files with 23 additions and 1 deletions
17
add.s
Normal file
17
add.s
Normal file
|
@ -0,0 +1,17 @@
|
|||
.globl add
|
||||
.text
|
||||
.align 2
|
||||
.type add, @function
|
||||
add:
|
||||
addi sp,sp,-32
|
||||
sw ra,28(sp)
|
||||
sw s0,24(sp)
|
||||
addi s0,sp,32
|
||||
sw a0,-20(s0)
|
||||
lw a5,-20(s0)
|
||||
slli a5,a5,1
|
||||
mv a0,a5
|
||||
lw ra,28(sp)
|
||||
lw s0,24(sp)
|
||||
addi sp,sp,32
|
||||
jr ra
|
3
link.ld
3
link.ld
|
@ -7,12 +7,15 @@ SECTIONS {
|
|||
.text : {
|
||||
main.o(.text.*)
|
||||
*(.text)
|
||||
. = ALIGN(4);
|
||||
} > DRAM
|
||||
.data : {
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
} > DRAM AT > SRAM
|
||||
.bss : {
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
} > DRAM
|
||||
/DISCARD/ : {
|
||||
*(.riscv.attributes)
|
||||
|
|
1
main.s
1
main.s
|
@ -1,6 +1,5 @@
|
|||
# Define variables
|
||||
.data
|
||||
.align 4
|
||||
num1: .word 5 # First number
|
||||
num2: .word 7 # Second number
|
||||
result: .word 0 # Variable to store the result
|
||||
|
|
3
makefile
3
makefile
|
@ -84,6 +84,9 @@ data: all
|
|||
size: all
|
||||
$(SIZE) $(TARGET)
|
||||
|
||||
format:
|
||||
clang-format -i *.s
|
||||
|
||||
# Clean up
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJS)
|
||||
|
|
Loading…
Reference in a new issue