- call crt stuff correctly

git-svn-id: http://moon:8086/svn/mips@111 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-21 12:09:38 +00:00
parent ae41d3dc9e
commit 40fb6cfab8
2 changed files with 34 additions and 39 deletions
+6 -3
View File
@@ -1,10 +1,13 @@
#include <regdef.h> #include <regdef.h>
#include <xcpt_asm.h> #include <xcpt_asm.h>
.section .exc_vect .text
.section .exc_vect, "ax"
.align 2
_xcpt_vector_tbl: _xcpt_vector_tbl:
.fill 16, 4, 0 la k0, _xcpt_handler
jr k0
nop
.text .text
LEAF(_xcpt_handler) LEAF(_xcpt_handler)
+28 -36
View File
@@ -1,3 +1,4 @@
#include <regdef.h>
.file "startup.S" .file "startup.S"
.section .rodata .section .rodata
@@ -6,19 +7,27 @@ argv0: .asciz "\"This-MIPS-program\""
argv: .word argv0 argv: .word argv0
.text .text
.section .init, "ax" .section .start, "ax"
.extern board_init .extern _init
.extern _exc_vect_start .extern _bss_zero
.extern _xcpt_handler
.align 2 .align 2
_start:
.set noreorder .set noreorder
# Set stack pointer _start:
la $sp, stack_ptr la sp, stack_ptr
# Set global pointer la gp, _gp
la $gp, _gp la ra, _bss_zero
j _init
nop
.text
.section .text, "ax"
.globl _bss_zero
.extern board_init
.align 2
.set noreorder
_bss_zero:
# zero bss # zero bss
la $8, __bss_start la $8, __bss_start
la $9, _end la $9, _end
@@ -27,43 +36,26 @@ $zeroise:
bne $8, $9, $zeroise bne $8, $9, $zeroise
addiu $8, 4 addiu $8, 4
# Install exception vector jump code _board_init:
la $t1, _exc_vect_copy_start
la $t2, _exc_vect_copy_end
la $t0, _exc_vect_start
$install: lw $v0, 0($t1)
addiu $t1, 4
sw $v0, 0($t0)
bne $t1, $t2, $install
addiu $t0, 4
_init:
# Call board_init # Call board_init
la $k0, board_init la k0, board_init
jalr $k0 jalr k0
nop nop
# Set environment # Set environment
li $a0, 1 li a0, 1
la $a1, argv la a1, argv
# Call main # Call main
la $k0, main la k0, main
jalr $k0 jalr k0
nop nop
# Terminate after main returns # Terminate after main returns
_terminate: _terminate:
nop nop
la $t0, exit la t0, exit
jalr $t0 jalr t0
move $a0, $v0 move a0, v0
_exc_vect_copy_start:
la $k0, _xcpt_handler
jr $k0
nop
_exc_vect_copy_end:
.set reorder .set reorder