-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e392609
Showing
7 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
riscv64-unknown-elf-gcc.exe -E -o ./main.i ./main.c | ||
|
||
riscv64-unknown-elf-gcc.exe -S -o ./main.S ./main.c | ||
|
||
riscv64-unknown-elf-gcc.exe -c -o ./main.o ./main.c | ||
|
||
|
||
riscv64-unknown-elf-objdump.exe -h ./main.o | ||
|
||
|
||
riscv64-unknown-elf-gcc.exe -nostdlib -T scratchpad.ld -o ./main.elf ./main.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
.file "main.c" | ||
.option nopic | ||
.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0" | ||
.attribute unaligned_access, 0 | ||
.attribute stack_align, 16 | ||
.text | ||
.align 1 | ||
.type simpleDelay, @function | ||
simpleDelay: | ||
addi sp,sp,-32 | ||
sd s0,24(sp) | ||
addi s0,sp,32 | ||
sw zero,-20(s0) | ||
j .L2 | ||
.L3: | ||
#APP | ||
# 16 "./main.c" 1 | ||
nop | ||
# 0 "" 2 | ||
#NO_APP | ||
lw a5,-20(s0) | ||
addiw a5,a5,1 | ||
sw a5,-20(s0) | ||
.L2: | ||
lw a5,-20(s0) | ||
sext.w a4,a5 | ||
li a5,999424 | ||
addi a5,a5,575 | ||
ble a4,a5,.L3 | ||
nop | ||
nop | ||
ld s0,24(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size simpleDelay, .-simpleDelay | ||
.align 1 | ||
.globl main | ||
.type main, @function | ||
main: | ||
addi sp,sp,-16 | ||
sd ra,8(sp) | ||
sd s0,0(sp) | ||
addi s0,sp,16 | ||
li a5,268500992 | ||
li a4,1 | ||
sw a4,0(a5) | ||
.L5: | ||
li a5,268500992 | ||
lw a5,0(a5) | ||
sext.w a4,a5 | ||
li a5,268500992 | ||
ori a4,a4,1 | ||
sext.w a4,a4 | ||
sw a4,0(a5) | ||
call simpleDelay | ||
li a5,268500992 | ||
lw a5,0(a5) | ||
sext.w a4,a5 | ||
li a5,268500992 | ||
andi a4,a4,-2 | ||
sext.w a4,a4 | ||
sw a4,0(a5) | ||
call simpleDelay | ||
j .L5 | ||
.size main, .-main | ||
.ident "GCC: (SiFive GCC-Metal 10.2.0-2020.12.8) 10.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#define SET_BITS(REG, BIT) ((REG) |= (BIT)) | ||
#define CLEAR_BITS(REG, BIT) ((REG) &= ~(BIT)) | ||
|
||
#define GPIOA_BASE 0x10010000U | ||
|
||
#define GPIO_PIN_0 0b0001U | ||
#define GPIO_PIN_1 0b0001U | ||
#define GPIO_PIN_2 0b0001U | ||
#define GPIO_PIN_3 0b0001U | ||
|
||
|
||
|
||
|
||
static inline void simpleDelay() { | ||
for (int i=0; i<1000000; i+=1) { | ||
__asm__("nop"); | ||
} | ||
} | ||
|
||
int main() { | ||
*(unsigned int volatile *)(GPIOA_BASE + 0x00U) = GPIO_PIN_0; | ||
|
||
while (1) { | ||
SET_BITS(*(unsigned int volatile *)(GPIOA_BASE + 0x00U), GPIO_PIN_0); | ||
simpleDelay(); | ||
|
||
CLEAR_BITS(*(unsigned int volatile *)(GPIOA_BASE + 0x00U), GPIO_PIN_0); | ||
simpleDelay(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 1 "./main.c" | ||
# 1 "<built-in>" | ||
# 1 "<command-line>" | ||
# 1 "./main.c" | ||
# 14 "./main.c" | ||
static inline void simpleDelay() { | ||
for (int i=0; i<1000000; i+=1) { | ||
__asm__("nop"); | ||
} | ||
} | ||
|
||
int main() { | ||
*(unsigned int volatile *)(0x10010000U + 0x00U) = 0b0001U; | ||
|
||
while (1) { | ||
((*(unsigned int volatile *)(0x10010000U + 0x00U)) |= (0b0001U)); | ||
simpleDelay(); | ||
|
||
((*(unsigned int volatile *)(0x10010000U + 0x00U)) &= ~(0b0001U)); | ||
simpleDelay(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
ENTRY(main) | ||
|
||
MEMORY { | ||
SCRATCHPAD(rwx): ORIGIN = 0x08000000, LENGTH = 4K | ||
} | ||
|
||
SECTIONS { | ||
.text : { | ||
*(.text) | ||
}> SCRATCHPAD | ||
} |