|
| 1 | +.set push |
| 2 | +.set noreorder |
| 3 | +.set noat |
| 4 | + |
| 5 | +#include <mipsregs.h> |
| 6 | + |
| 7 | +.text |
| 8 | + |
| 9 | +// sizeof() == 0x3C(60) |
| 10 | +#define ExecInfo_entry 0x00 // Address of program entry-point. |
| 11 | +#define ExecInfo_init_gp 0x04 // SCE only. Initial value the "gp" register is set to. 0 for PS-X EXE. |
| 12 | +#define ExecInfo_text_addr 0x08 // Memory address to which the .text section is loaded. |
| 13 | +#define ExecInfo_text_size 0x0C // Size of the .text section in the file and memory. |
| 14 | +#define ExecInfo_data_addr 0x10 // SCE only. Memory address to which the .data section is loaded. 0 for PS-X EXE. |
| 15 | +#define ExecInfo_data_size 0x14 // SCE only. Size of the .data section in the file and memory. 0 for PS-X EXE. |
| 16 | +#define ExecInfo_bss_addr 0x18 // Memory address of the .bss section. .bss is initialized by Exec(). |
| 17 | +#define ExecInfo_bss_size 0x1C // Size of the .bss section in memory. |
| 18 | +#define ExecInfo_stack_addr 0x20 // Memory address pointing to the bottom(lowest address) of the stack. BIOS replaces |
| 19 | + // with "STACK" parameter of "SYSTEM.CNF" file. |
| 20 | +#define ExecInfo_stack_size 0x24 // Size of the stack. Can be 0. |
| 21 | +#define ExecInfo_saved_sp 0x28 // Used by BIOS Exec() function to preserve the "sp" register. |
| 22 | +#define ExecInfo_saved_fp 0x2C // Used by BIOS Exec() function to preserve the "fp" register. |
| 23 | +#define ExecInfo_saved_gp 0x30 // Used by BIOS Exec() function to preserve the "gp" register. |
| 24 | +#define ExecInfo_saved_ra 0x34 // Used by BIOS Exec() function to preserve the "ra" register. |
| 25 | +#define ExecInfo_saved_s0 0x38 // Used by BIOS Exec() function to preserve the "s0" register. |
| 26 | + |
| 27 | +.global Exec2 |
| 28 | +.type Exec2, @function |
| 29 | +.ent Exec2 |
| 30 | +Exec2: |
| 31 | + sw s0, ExecInfo_saved_s0(a0) |
| 32 | + or s0, zero, a0 |
| 33 | + sw ra, ExecInfo_saved_ra(s0) |
| 34 | + sw sp, ExecInfo_saved_sp(s0) |
| 35 | + sw fp, ExecInfo_saved_fp(s0) |
| 36 | + lw t0, ExecInfo_bss_size(s0) |
| 37 | + sw gp, ExecInfo_saved_gp(s0) |
| 38 | + |
| 39 | + beqz t0, _no_bss |
| 40 | + |
| 41 | + lw t1, ExecInfo_bss_addr(s0) |
| 42 | + nop |
| 43 | +_bss_clear_loop: |
| 44 | + addiu t0, t0, -4 |
| 45 | + sw zero, 0(t1) |
| 46 | + bgtz t0, _bss_clear_loop |
| 47 | + addiu t1, t1, 4 |
| 48 | + |
| 49 | +_no_bss: |
| 50 | + lw t0, ExecInfo_stack_addr(s0) |
| 51 | + nop |
| 52 | + beqz t0, _no_stack |
| 53 | + nop |
| 54 | + |
| 55 | + lw t1, ExecInfo_stack_size(s0) |
| 56 | + nop |
| 57 | + add t0, t1 |
| 58 | + move sp, t0 |
| 59 | + move fp, sp |
| 60 | + |
| 61 | + |
| 62 | +_no_stack: |
| 63 | + lw t3, ExecInfo_entry(s0) |
| 64 | + lw gp, ExecInfo_init_gp(s0) |
| 65 | + move a0, a1 |
| 66 | + jalr t3 |
| 67 | + move a1, a2 |
| 68 | + |
| 69 | + lw ra, ExecInfo_saved_ra(s0) |
| 70 | + lw sp, ExecInfo_saved_sp(s0) |
| 71 | + lw fp, ExecInfo_saved_fp(s0) |
| 72 | + lw gp, ExecInfo_saved_gp(s0) |
| 73 | + lw s0, ExecInfo_saved_s0(s0) |
| 74 | + jr ra |
| 75 | + li v0, 1 |
| 76 | +.end Exec2 |
0 commit comments