fixed infinite loop when not branching
This commit is contained in:
BIN
tests/1.bin
BIN
tests/1.bin
Binary file not shown.
10
tests/1.c
Normal file
10
tests/1.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
int main(){
|
||||
uint8_t* ptr = 0x800000F0;
|
||||
|
||||
for(int i = 0; i < 16; i++){
|
||||
*ptr = i;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
40
tests/1.s
Normal file
40
tests/1.s
Normal file
@@ -0,0 +1,40 @@
|
||||
.file "1.c"
|
||||
.option nopic
|
||||
.attribute arch, "rv32i2p1"
|
||||
.attribute unaligned_access, 0
|
||||
.attribute stack_align, 16
|
||||
.text
|
||||
.align 2
|
||||
.globl main
|
||||
.type main, @function
|
||||
main:
|
||||
addi sp,sp,-32
|
||||
sw s0,28(sp)
|
||||
addi s0,sp,32
|
||||
li a5,-2147483648
|
||||
addi a5,a5,240
|
||||
sw a5,-20(s0)
|
||||
sw zero,-24(s0)
|
||||
j .L2
|
||||
.L3:
|
||||
lw a5,-24(s0)
|
||||
andi a4,a5,0xff
|
||||
lw a5,-20(s0)
|
||||
sb a4,0(a5)
|
||||
lw a5,-20(s0)
|
||||
addi a5,a5,1
|
||||
sw a5,-20(s0)
|
||||
lw a5,-24(s0)
|
||||
addi a5,a5,1
|
||||
sw a5,-24(s0)
|
||||
.L2:
|
||||
lw a4,-24(s0)
|
||||
li a5,15
|
||||
ble a4,a5,.L3
|
||||
li a5,0
|
||||
mv a0,a5
|
||||
lw s0,28(sp)
|
||||
addi sp,sp,32
|
||||
jr ra
|
||||
.size main, .-main
|
||||
.ident "GCC: () 13.2.0"
|
||||
BIN
tests/a.out
BIN
tests/a.out
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
int main(){
|
||||
|
||||
}
|
||||
20
tests/main.s
20
tests/main.s
@@ -1,20 +0,0 @@
|
||||
.file "main.c"
|
||||
.option nopic
|
||||
.attribute arch, "rv32i2p1"
|
||||
.attribute unaligned_access, 0
|
||||
.attribute stack_align, 16
|
||||
.text
|
||||
.align 2
|
||||
.globl main
|
||||
.type main, @function
|
||||
main:
|
||||
addi sp,sp,-16
|
||||
sw s0,12(sp)
|
||||
addi s0,sp,16
|
||||
li a5,0
|
||||
mv a0,a5
|
||||
lw s0,12(sp)
|
||||
addi sp,sp,16
|
||||
jr ra
|
||||
.size main, .-main
|
||||
.ident "GCC: () 13.2.0"
|
||||
Reference in New Issue
Block a user