summaryrefslogtreecommitdiff
path: root/riscv_new/rtl/linux/riscv64/prt0.as
diff options
context:
space:
mode:
Diffstat (limited to 'riscv_new/rtl/linux/riscv64/prt0.as')
-rw-r--r--riscv_new/rtl/linux/riscv64/prt0.as83
1 files changed, 83 insertions, 0 deletions
diff --git a/riscv_new/rtl/linux/riscv64/prt0.as b/riscv_new/rtl/linux/riscv64/prt0.as
new file mode 100644
index 0000000000..d489b5dcad
--- /dev/null
+++ b/riscv_new/rtl/linux/riscv64/prt0.as
@@ -0,0 +1,83 @@
+/*
+ Start-up code for Free Pascal Compiler, not in a shared library,
+ not linking with C library.
+
+ Written by Edmund Grimley Evans in 2015 and released into the public domain.
+*/
+
+ .text
+ .align 2
+
+ .globl _dynamic_start
+ .type _dynamic_start, function
+_dynamic_start:
+1:
+ auipc x5,%pcrel_hi(__dl_fini)
+ sd x10, %pcrel_lo(1b)(x5)
+ jal x0, _start
+
+ .globl _start
+ .type _start, function
+_start:
+1:
+ auipc gp, %pcrel_hi(__bss_start+0x800)
+ addi gp, gp, %pcrel_lo(1b)
+
+ /* Get argc, argv, envp */
+ ld x5,(x2)
+ addi x6,x2,8
+ addi x7,x5,1
+ slli x7,x7,3
+ add x7,x6,x7
+
+ /* Save argc, argv, envp, and initial stack pointer */
+1:auipc x8,%pcrel_hi(operatingsystem_parameter_argc)
+ sd x5,%pcrel_lo(1b)(x8)
+1:auipc x8,%pcrel_hi(operatingsystem_parameter_argv)
+ sd x6,%pcrel_lo(1b)(x8)
+1:auipc x8,%pcrel_hi(operatingsystem_parameter_envp)
+ sd x7,%pcrel_lo(1b)(x8)
+1:auipc x5,%pcrel_hi(__stkptr)
+ addi x6, x2, 0
+ sd x6,%pcrel_lo(1b)(x5)
+
+ /* Initialise FP to zero */
+ addi x8,x0,0
+
+ /* Call main */
+ jal x1, PASCALMAIN
+
+ .globl _haltproc
+ .type _haltproc,function
+_haltproc:
+1:auipc x10,%pcrel_hi(__dl_fini)
+ ld x10,%pcrel_lo(1b)(x10)
+ beq x10,x0,.Lexit
+ jalr x1,x10
+.Lexit:
+1:auipc x10,%pcrel_hi(operatingsystem_result)
+ ld x10,%pcrel_lo(1b)(x10)
+ addi x17, x0, 94
+ ecall
+ jal x0, _haltproc
+
+ /* Define a symbol for the first piece of initialized data. */
+ .data
+ .align 4
+ .globl __data_start
+__data_start:
+ .quad 0
+ .weak data_start
+ data_start = __data_start
+
+ .bss
+ .align 4
+
+ .comm __dl_fini,8
+ .comm __stkptr,8
+
+ .comm operatingsystem_parameter_envp,8
+ .comm operatingsystem_parameter_argc,8
+ .comm operatingsystem_parameter_argv,8
+
+ .section .note.GNU-stack,"",%progbits