mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 21:28:03 +02:00
* more properties fixed
git-svn-id: trunk@8210 -
This commit is contained in:
parent
065b187c26
commit
9713d5cb21
76
.gitattributes
vendored
76
.gitattributes
vendored
@ -4387,7 +4387,7 @@ rtl/arm/setjumph.inc svneol=native#text/plain
|
||||
rtl/arm/strings.inc svneol=native#text/plain
|
||||
rtl/arm/stringss.inc svneol=native#text/plain
|
||||
rtl/atari/os.inc svneol=native#text/plain
|
||||
rtl/atari/prt0.as -text
|
||||
rtl/atari/prt0.as svneol=native#text/plain
|
||||
rtl/atari/readme -text
|
||||
rtl/atari/sysatari.pas svneol=native#text/plain
|
||||
rtl/atari/system.pas svneol=native#text/plain
|
||||
@ -4398,11 +4398,11 @@ rtl/beos/bethreads.pp svneol=native#text/plain
|
||||
rtl/beos/classes.pp svneol=native#text/plain
|
||||
rtl/beos/errno.inc svneol=native#text/plain
|
||||
rtl/beos/errnostr.inc svneol=native#text/plain
|
||||
rtl/beos/i386/cprt0.as -text
|
||||
rtl/beos/i386/dllprt.as -text
|
||||
rtl/beos/i386/cprt0.as svneol=native#text/plain
|
||||
rtl/beos/i386/dllprt.as svneol=native#text/plain
|
||||
rtl/beos/i386/dllprt.cpp -text
|
||||
rtl/beos/i386/func.as -text
|
||||
rtl/beos/i386/prt0.as -text
|
||||
rtl/beos/i386/func.as svneol=native#text/plain
|
||||
rtl/beos/i386/prt0.as svneol=native#text/plain
|
||||
rtl/beos/osmacro.inc svneol=native#text/plain
|
||||
rtl/beos/osposixh.inc svneol=native#text/plain
|
||||
rtl/beos/ossysc.inc svneol=native#text/plain
|
||||
@ -4498,8 +4498,8 @@ rtl/emx/emx.imp -text
|
||||
rtl/emx/emx.pas svneol=native#text/plain
|
||||
rtl/emx/emxwrap.imp -text
|
||||
rtl/emx/ports.pas svneol=native#text/plain
|
||||
rtl/emx/prt0.as -text
|
||||
rtl/emx/prt1.as -text
|
||||
rtl/emx/prt0.as svneol=native#text/plain
|
||||
rtl/emx/prt1.as svneol=native#text/plain
|
||||
rtl/emx/sysdir.inc svneol=native#text/plain
|
||||
rtl/emx/sysemx.pas svneol=native#text/plain
|
||||
rtl/emx/sysfile.inc svneol=native#text/plain
|
||||
@ -4519,9 +4519,9 @@ rtl/freebsd/errno.inc svneol=native#text/plain
|
||||
rtl/freebsd/errnostr.inc -text
|
||||
rtl/freebsd/freebsd.pas -text
|
||||
rtl/freebsd/i386/bsyscall.inc svneol=native#text/plain
|
||||
rtl/freebsd/i386/cprt0.as -text
|
||||
rtl/freebsd/i386/gprt0.as -text
|
||||
rtl/freebsd/i386/prt0.as -text
|
||||
rtl/freebsd/i386/cprt0.as svneol=native#text/plain
|
||||
rtl/freebsd/i386/gprt0.as svneol=native#text/plain
|
||||
rtl/freebsd/i386/prt0.as svneol=native#text/plain
|
||||
rtl/freebsd/i386/sighnd.inc svneol=native#text/plain
|
||||
rtl/freebsd/i386/x86.inc svneol=native#text/plain
|
||||
rtl/freebsd/i386/x86h.inc svneol=native#text/plain
|
||||
@ -4541,17 +4541,17 @@ rtl/freebsd/unxfunc.inc svneol=native#text/plain
|
||||
rtl/freebsd/unxsockh.inc svneol=native#text/plain
|
||||
rtl/freebsd/unxsysc.inc svneol=native#text/plain
|
||||
rtl/freebsd/x86_64/bsyscall.inc svneol=native#text/plain
|
||||
rtl/freebsd/x86_64/prt0.as -text
|
||||
rtl/freebsd/x86_64/prt0.as svneol=native#text/plain
|
||||
rtl/freebsd/x86_64/sighnd.inc svneol=native#text/plain
|
||||
rtl/gba/Makefile svneol=native#text/plain
|
||||
rtl/gba/Makefile.fpc svneol=native#text/plain
|
||||
rtl/gba/classes.pp svneol=native#text/plain
|
||||
rtl/gba/cprt0.as -text
|
||||
rtl/gba/cprt0.as svneol=native#text/plain
|
||||
rtl/gba/dos.pp svneol=native#text/plain
|
||||
rtl/gba/gbabios.inc svneol=native#text/plain
|
||||
rtl/gba/gbabiosh.inc svneol=native#text/plain
|
||||
rtl/gba/lnkscript -text
|
||||
rtl/gba/prt0.as -text
|
||||
rtl/gba/prt0.as svneol=native#text/plain
|
||||
rtl/gba/sysdir.inc svneol=native#text/plain
|
||||
rtl/gba/sysfile.inc svneol=native#text/plain
|
||||
rtl/gba/sysheap.inc svneol=native#text/plain
|
||||
@ -4572,10 +4572,10 @@ rtl/go32v2/dpmiexcp.pp svneol=native#text/plain
|
||||
rtl/go32v2/dxeload.pp svneol=native#text/plain
|
||||
rtl/go32v2/dxetype.pp svneol=native#text/plain
|
||||
rtl/go32v2/emu387.pp svneol=native#text/plain
|
||||
rtl/go32v2/exceptn.as -text
|
||||
rtl/go32v2/exceptn.as svneol=native#text/plain
|
||||
rtl/go32v2/exit16.ah -text
|
||||
rtl/go32v2/exit16.asm -text
|
||||
rtl/go32v2/fpu.as -text
|
||||
rtl/go32v2/fpu.as svneol=native#text/plain
|
||||
rtl/go32v2/go32.pp svneol=native#text/plain
|
||||
rtl/go32v2/initc.pp svneol=native#text/plain
|
||||
rtl/go32v2/keyboard.pp svneol=native#text/plain
|
||||
@ -4595,7 +4595,7 @@ rtl/go32v2/system.pp svneol=native#text/plain
|
||||
rtl/go32v2/systhrd.inc svneol=native#text/plain
|
||||
rtl/go32v2/sysutils.pp svneol=native#text/plain
|
||||
rtl/go32v2/tthread.inc svneol=native#text/plain
|
||||
rtl/go32v2/v2prt0.as -text
|
||||
rtl/go32v2/v2prt0.as svneol=native#text/plain
|
||||
rtl/go32v2/varutils.pp svneol=native#text/plain
|
||||
rtl/go32v2/vesamode.pp svneol=native#text/plain
|
||||
rtl/go32v2/video.pp svneol=native#text/plain
|
||||
@ -4886,7 +4886,7 @@ rtl/morphos/layers.pas svneol=native#text/plain
|
||||
rtl/morphos/mouse.pp svneol=native#text/plain
|
||||
rtl/morphos/mui.pas -text
|
||||
rtl/morphos/muihelper.pas -text
|
||||
rtl/morphos/prt0.as -text
|
||||
rtl/morphos/prt0.as svneol=native#text/plain
|
||||
rtl/morphos/sockets.pp svneol=native#text/plain
|
||||
rtl/morphos/sysdir.inc svneol=native#text/plain
|
||||
rtl/morphos/sysfile.inc svneol=native#text/plain
|
||||
@ -4911,13 +4911,13 @@ rtl/morphos/videodata.inc svneol=native#text/plain
|
||||
rtl/nds/Makefile svneol=native#text/plain
|
||||
rtl/nds/Makefile.fpc -text
|
||||
rtl/nds/classes.pp -text
|
||||
rtl/nds/cprt07.as -text
|
||||
rtl/nds/cprt09.as -text
|
||||
rtl/nds/cprt07.as svneol=native#text/plain
|
||||
rtl/nds/cprt09.as svneol=native#text/plain
|
||||
rtl/nds/dos.pp -text
|
||||
rtl/nds/ndsbios.inc -text
|
||||
rtl/nds/ndsbiosh.inc -text
|
||||
rtl/nds/prt07.as -text
|
||||
rtl/nds/prt09.as -text
|
||||
rtl/nds/prt07.as svneol=native#text/plain
|
||||
rtl/nds/prt09.as svneol=native#text/plain
|
||||
rtl/nds/sysdir.inc -text
|
||||
rtl/nds/sysfile.inc -text
|
||||
rtl/nds/sysheap.inc svneol=native#text/x-pascal
|
||||
@ -4932,13 +4932,13 @@ rtl/netbsd/Makefile.fpc svneol=native#text/plain
|
||||
rtl/netbsd/errno.inc svneol=native#text/plain
|
||||
rtl/netbsd/errnostr.inc -text
|
||||
rtl/netbsd/i386/bsyscall.inc svneol=native#text/plain
|
||||
rtl/netbsd/i386/cprt0.as -text
|
||||
rtl/netbsd/i386/prt0.as -text
|
||||
rtl/netbsd/i386/prt0_10.as -text
|
||||
rtl/netbsd/i386/cprt0.as svneol=native#text/plain
|
||||
rtl/netbsd/i386/prt0.as svneol=native#text/plain
|
||||
rtl/netbsd/i386/prt0_10.as svneol=native#text/plain
|
||||
rtl/netbsd/i386/sighnd.inc svneol=native#text/plain
|
||||
rtl/netbsd/pmutext.inc svneol=native#text/plain
|
||||
rtl/netbsd/powerpc/cprt0.as -text
|
||||
rtl/netbsd/powerpc/prt0.as -text
|
||||
rtl/netbsd/powerpc/cprt0.as svneol=native#text/plain
|
||||
rtl/netbsd/powerpc/prt0.as svneol=native#text/plain
|
||||
rtl/netbsd/powerpc/sighnd.inc svneol=native#text/plain
|
||||
rtl/netbsd/ptypes.inc svneol=native#text/plain
|
||||
rtl/netbsd/signal.inc svneol=native#text/plain
|
||||
@ -4994,7 +4994,7 @@ rtl/netware/npackoff.inc svneol=native#text/plain
|
||||
rtl/netware/npackon.inc svneol=native#text/plain
|
||||
rtl/netware/nwcalls.pp svneol=native#text/plain
|
||||
rtl/netware/nwnit.pp svneol=native#text/plain
|
||||
rtl/netware/nwpre.as -text
|
||||
rtl/netware/nwpre.as svneol=native#text/plain
|
||||
rtl/netware/nwpre.pp svneol=native#text/plain
|
||||
rtl/netware/nwprot.pp svneol=native#text/plain
|
||||
rtl/netware/nwpsrv.imp -text
|
||||
@ -5004,7 +5004,7 @@ rtl/netware/nwsnut.imp -text
|
||||
rtl/netware/nwsnut.pp svneol=native#text/plain
|
||||
rtl/netware/nwsock.inc svneol=native#text/plain
|
||||
rtl/netware/nwsys.inc svneol=native#text/plain
|
||||
rtl/netware/prelude.as -text
|
||||
rtl/netware/prelude.as svneol=native#text/plain
|
||||
rtl/netware/qos.inc svneol=native#text/plain
|
||||
rtl/netware/requestr.imp -text
|
||||
rtl/netware/sockets.pp svneol=native#text/plain
|
||||
@ -5045,8 +5045,8 @@ rtl/netwlibc/libcclib.imp -text
|
||||
rtl/netwlibc/mouse.pp svneol=native#text/plain
|
||||
rtl/netwlibc/netware.imp -text
|
||||
rtl/netwlibc/netwsockh.inc svneol=native#text/plain
|
||||
rtl/netwlibc/nwl_dlle.as -text
|
||||
rtl/netwlibc/nwl_main.as -text
|
||||
rtl/netwlibc/nwl_dlle.as svneol=native#text/plain
|
||||
rtl/netwlibc/nwl_main.as svneol=native#text/plain
|
||||
rtl/netwlibc/nwsnut.imp -text
|
||||
rtl/netwlibc/nwsnut.pp svneol=native#text/plain
|
||||
rtl/netwlibc/pre/libcpre.gcc.o -text
|
||||
@ -5143,8 +5143,8 @@ rtl/openbsd/Makefile svneol=native#text/plain
|
||||
rtl/openbsd/Makefile.fpc svneol=native#text/plain
|
||||
rtl/openbsd/classes.pp svneol=native#text/plain
|
||||
rtl/openbsd/errno.inc svneol=native#text/plain
|
||||
rtl/openbsd/i386/cprt0.as -text
|
||||
rtl/openbsd/i386/prt0.as -text
|
||||
rtl/openbsd/i386/cprt0.as svneol=native#text/plain
|
||||
rtl/openbsd/i386/prt0.as svneol=native#text/plain
|
||||
rtl/openbsd/i386/sighnd.inc svneol=native#text/plain
|
||||
rtl/openbsd/pmutext.inc svneol=native#text/plain
|
||||
rtl/openbsd/ptypes.inc svneol=native#text/plain
|
||||
@ -5189,7 +5189,7 @@ rtl/os2/pmwp.pas svneol=native#text/plain
|
||||
rtl/os2/pmwsock.pas svneol=native#text/plain
|
||||
rtl/os2/ports.pas svneol=native#text/plain
|
||||
rtl/os2/printer.pas svneol=native#text/plain
|
||||
rtl/os2/prt0.as -text
|
||||
rtl/os2/prt0.as svneol=native#text/plain
|
||||
rtl/os2/so32dll.pas svneol=native#text/plain
|
||||
rtl/os2/sockets.pas svneol=native#text/plain
|
||||
rtl/os2/sysdir.inc svneol=native#text/plain
|
||||
@ -5237,7 +5237,7 @@ rtl/palmos/api/sysall.pp svneol=native#text/plain
|
||||
rtl/palmos/api/systraps.inc svneol=native#text/plain
|
||||
rtl/palmos/api/systraps.pp svneol=native#text/plain
|
||||
rtl/palmos/api/ui.pp svneol=native#text/plain
|
||||
rtl/palmos/arm/prt0.as -text
|
||||
rtl/palmos/arm/prt0.as svneol=native#text/plain
|
||||
rtl/palmos/os.inc svneol=native#text/plain
|
||||
rtl/palmos/pilot.pp svneol=native#text/plain
|
||||
rtl/palmos/readme -text
|
||||
@ -5472,7 +5472,7 @@ rtl/win32/Makefile svneol=native#text/plain
|
||||
rtl/win32/Makefile.fpc svneol=native#text/plain
|
||||
rtl/win32/buildrtl.pp svneol=native#text/plain
|
||||
rtl/win32/classes.pp svneol=native#text/plain
|
||||
rtl/win32/gprt0.as -text
|
||||
rtl/win32/gprt0.as svneol=native#text/plain
|
||||
rtl/win32/initc.pp svneol=native#text/plain
|
||||
rtl/win32/objinc.inc svneol=native#text/plain
|
||||
rtl/win32/signals.pp svneol=native#text/plain
|
||||
@ -5480,11 +5480,11 @@ rtl/win32/sysinitcyg.pp svneol=native#text/plain
|
||||
rtl/win32/sysinitgprof.pp svneol=native#text/plain
|
||||
rtl/win32/sysinitpas.pp svneol=native#text/plain
|
||||
rtl/win32/system.pp svneol=native#text/plain
|
||||
rtl/win32/wcygprt0.as -text
|
||||
rtl/win32/wdllprt0.as -text
|
||||
rtl/win32/wcygprt0.as svneol=native#text/plain
|
||||
rtl/win32/wdllprt0.as svneol=native#text/plain
|
||||
rtl/win32/windows.pp svneol=native#text/plain
|
||||
rtl/win32/winsysut.pp svneol=native#text/plain
|
||||
rtl/win32/wprt0.as -text
|
||||
rtl/win32/wprt0.as svneol=native#text/plain
|
||||
rtl/win64/Makefile svneol=native#text/plain
|
||||
rtl/win64/Makefile.fpc svneol=native#text/plain
|
||||
rtl/win64/buildrtl.pp svneol=native#text/plain
|
||||
|
488
rtl/gba/cprt0.as
488
rtl/gba/cprt0.as
@ -1,244 +1,244 @@
|
||||
@ (c) 2006 by devkitPro (http://www.devkitpro.org)
|
||||
|
||||
|
||||
.section ".init"
|
||||
.global _start
|
||||
.align
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
b rom_header_end
|
||||
|
||||
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
|
||||
.fill 16,1,0 @ Game Title
|
||||
.byte 0x30,0x31 @ Maker Code (80000B0h)
|
||||
.byte 0x96 @ Fixed Value (80000B2h)
|
||||
.byte 0x00 @ Main Unit Code (80000B3h)
|
||||
.byte 0x00 @ Device Type (80000B4h)
|
||||
.fill 7,1,0 @ unused
|
||||
.byte 0x00 @ Software Version No (80000BCh)
|
||||
.byte 0xf0 @ Complement Check (80000BDh)
|
||||
.byte 0x00,0x00 @ Checksum (80000BEh)
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
rom_header_end:
|
||||
@---------------------------------------------------------------------------------
|
||||
b start_vector @ This branch must be here for proper
|
||||
@ positioning of the following header.
|
||||
|
||||
.GLOBAL __boot_method, __slave_number
|
||||
@---------------------------------------------------------------------------------
|
||||
__boot_method:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
|
||||
@---------------------------------------------------------------------------------
|
||||
__slave_number:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
|
||||
|
||||
.byte 0 @ reserved
|
||||
.byte 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
|
||||
.global start_vector
|
||||
.align
|
||||
@---------------------------------------------------------------------------------
|
||||
start_vector:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x4000000 @ REG_BASE
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
mov r0, #0x1f @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Enter Thumb mode
|
||||
@---------------------------------------------------------------------------------
|
||||
add r0, pc, #1
|
||||
bx r0
|
||||
|
||||
.thumb
|
||||
|
||||
ldr r0, =__text_start
|
||||
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
|
||||
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
|
||||
|
||||
mov r0, pc
|
||||
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
|
||||
bcc SkipEWRAMClear @ No, so no need to do a copy.
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ We were started in ROM, silly emulators. :P
|
||||
@ So we need to copy to ExWRAM.
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #2
|
||||
lsl r2, r2, #24 @ r2= 0x02000000
|
||||
ldr r3, =__end__ @ last ewram address
|
||||
sub r3, r2 @ r3= actual binary size
|
||||
mov r6, r2 @ r6= 0x02000000
|
||||
lsl r1, r2, #2 @ r1= 0x08000000
|
||||
|
||||
bl CopyMem
|
||||
|
||||
bx r6 @ Jump to the code to execute
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
DoEWRAMClear: @ Clear External WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r1, #0x40
|
||||
lsl r1, #12 @ r1 = 0x40000
|
||||
lsl r0, r1, #7 @ r0 = 0x2000000
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear BSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__bss_start
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear SBSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__sbss_start
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__data_lma
|
||||
ldr r2, =__data_start
|
||||
ldr r4, =__data_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1,= __iwram_lma
|
||||
ldr r2,= __iwram_start
|
||||
ldr r4,= __iwram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r2,= __load_stop_iwram0
|
||||
ldr r1,= __load_start_iwram0
|
||||
sub r3, r2, r1 @ Is there any data to copy?
|
||||
beq CIW0Skip @ no
|
||||
|
||||
ldr r2,= __iwram_overlay_start
|
||||
bl CopyMem
|
||||
@---------------------------------------------------------------------------------
|
||||
CIW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__ewram_lma
|
||||
ldr r2, =__ewram_start
|
||||
ldr r4, =__ewram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CEW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ set heap end
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =fake_heap_end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
@---------------------------------------------------------------------------------
|
||||
@ global constructors
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r3, =__libc_init_array
|
||||
bl _call_via_r3
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Jump to user code
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3, =main
|
||||
bl _call_via_r3
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2,#3 @ These commands are used in cases where
|
||||
add r1,r2 @ the length is not a multiple of 4,
|
||||
bic r1,r2 @ even though it should be.
|
||||
|
||||
beq ClearMX @ Length is zero so exit
|
||||
|
||||
mov r2,#0
|
||||
@---------------------------------------------------------------------------------
|
||||
ClrLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
stmia r0!, {r2}
|
||||
sub r1,#4
|
||||
bne ClrLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMX:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemChk:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r0 @ the length is not a multiple of 4,
|
||||
bic r3, r0 @ even though it should be.
|
||||
beq CIDExit @ Length is zero so exit
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
sub r3, #4
|
||||
bne CIDLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDExit:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
|
||||
@ (c) 2006 by devkitPro (http://www.devkitpro.org)
|
||||
|
||||
|
||||
.section ".init"
|
||||
.global _start
|
||||
.align
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
b rom_header_end
|
||||
|
||||
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
|
||||
.fill 16,1,0 @ Game Title
|
||||
.byte 0x30,0x31 @ Maker Code (80000B0h)
|
||||
.byte 0x96 @ Fixed Value (80000B2h)
|
||||
.byte 0x00 @ Main Unit Code (80000B3h)
|
||||
.byte 0x00 @ Device Type (80000B4h)
|
||||
.fill 7,1,0 @ unused
|
||||
.byte 0x00 @ Software Version No (80000BCh)
|
||||
.byte 0xf0 @ Complement Check (80000BDh)
|
||||
.byte 0x00,0x00 @ Checksum (80000BEh)
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
rom_header_end:
|
||||
@---------------------------------------------------------------------------------
|
||||
b start_vector @ This branch must be here for proper
|
||||
@ positioning of the following header.
|
||||
|
||||
.GLOBAL __boot_method, __slave_number
|
||||
@---------------------------------------------------------------------------------
|
||||
__boot_method:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
|
||||
@---------------------------------------------------------------------------------
|
||||
__slave_number:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
|
||||
|
||||
.byte 0 @ reserved
|
||||
.byte 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
|
||||
.global start_vector
|
||||
.align
|
||||
@---------------------------------------------------------------------------------
|
||||
start_vector:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x4000000 @ REG_BASE
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
mov r0, #0x1f @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Enter Thumb mode
|
||||
@---------------------------------------------------------------------------------
|
||||
add r0, pc, #1
|
||||
bx r0
|
||||
|
||||
.thumb
|
||||
|
||||
ldr r0, =__text_start
|
||||
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
|
||||
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
|
||||
|
||||
mov r0, pc
|
||||
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
|
||||
bcc SkipEWRAMClear @ No, so no need to do a copy.
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ We were started in ROM, silly emulators. :P
|
||||
@ So we need to copy to ExWRAM.
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #2
|
||||
lsl r2, r2, #24 @ r2= 0x02000000
|
||||
ldr r3, =__end__ @ last ewram address
|
||||
sub r3, r2 @ r3= actual binary size
|
||||
mov r6, r2 @ r6= 0x02000000
|
||||
lsl r1, r2, #2 @ r1= 0x08000000
|
||||
|
||||
bl CopyMem
|
||||
|
||||
bx r6 @ Jump to the code to execute
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
DoEWRAMClear: @ Clear External WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r1, #0x40
|
||||
lsl r1, #12 @ r1 = 0x40000
|
||||
lsl r0, r1, #7 @ r0 = 0x2000000
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear BSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__bss_start
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear SBSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__sbss_start
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__data_lma
|
||||
ldr r2, =__data_start
|
||||
ldr r4, =__data_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1,= __iwram_lma
|
||||
ldr r2,= __iwram_start
|
||||
ldr r4,= __iwram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r2,= __load_stop_iwram0
|
||||
ldr r1,= __load_start_iwram0
|
||||
sub r3, r2, r1 @ Is there any data to copy?
|
||||
beq CIW0Skip @ no
|
||||
|
||||
ldr r2,= __iwram_overlay_start
|
||||
bl CopyMem
|
||||
@---------------------------------------------------------------------------------
|
||||
CIW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__ewram_lma
|
||||
ldr r2, =__ewram_start
|
||||
ldr r4, =__ewram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CEW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ set heap end
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =fake_heap_end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
@---------------------------------------------------------------------------------
|
||||
@ global constructors
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r3, =__libc_init_array
|
||||
bl _call_via_r3
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Jump to user code
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3, =main
|
||||
bl _call_via_r3
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2,#3 @ These commands are used in cases where
|
||||
add r1,r2 @ the length is not a multiple of 4,
|
||||
bic r1,r2 @ even though it should be.
|
||||
|
||||
beq ClearMX @ Length is zero so exit
|
||||
|
||||
mov r2,#0
|
||||
@---------------------------------------------------------------------------------
|
||||
ClrLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
stmia r0!, {r2}
|
||||
sub r1,#4
|
||||
bne ClrLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMX:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemChk:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r0 @ the length is not a multiple of 4,
|
||||
bic r3, r0 @ even though it should be.
|
||||
beq CIDExit @ Length is zero so exit
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
sub r3, #4
|
||||
bne CIDLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDExit:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
|
||||
|
486
rtl/gba/prt0.as
486
rtl/gba/prt0.as
@ -1,243 +1,243 @@
|
||||
@ (c) 2006 by devkitPro (http://www.devkitpro.org)
|
||||
|
||||
|
||||
.section ".init"
|
||||
.global _start
|
||||
.align
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
b rom_header_end
|
||||
|
||||
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
|
||||
.fill 16,1,0 @ Game Title
|
||||
.byte 0x30,0x31 @ Maker Code (80000B0h)
|
||||
.byte 0x96 @ Fixed Value (80000B2h)
|
||||
.byte 0x00 @ Main Unit Code (80000B3h)
|
||||
.byte 0x00 @ Device Type (80000B4h)
|
||||
.fill 7,1,0 @ unused
|
||||
.byte 0x00 @ Software Version No (80000BCh)
|
||||
.byte 0xf0 @ Complement Check (80000BDh)
|
||||
.byte 0x00,0x00 @ Checksum (80000BEh)
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
rom_header_end:
|
||||
@---------------------------------------------------------------------------------
|
||||
b start_vector @ This branch must be here for proper
|
||||
@ positioning of the following header.
|
||||
|
||||
.GLOBAL __boot_method, __slave_number
|
||||
@---------------------------------------------------------------------------------
|
||||
__boot_method:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
|
||||
@---------------------------------------------------------------------------------
|
||||
__slave_number:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
|
||||
|
||||
.byte 0 @ reserved
|
||||
.byte 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
|
||||
.global start_vector
|
||||
.align
|
||||
@---------------------------------------------------------------------------------
|
||||
start_vector:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x4000000 @ REG_BASE
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
mov r0, #0x1f @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Enter Thumb mode
|
||||
@---------------------------------------------------------------------------------
|
||||
add r0, pc, #1
|
||||
bx r0
|
||||
|
||||
.thumb
|
||||
|
||||
ldr r0, =__text_start
|
||||
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
|
||||
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
|
||||
|
||||
mov r0, pc
|
||||
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
|
||||
bcc SkipEWRAMClear @ No, so no need to do a copy.
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ We were started in ROM, silly emulators. :P
|
||||
@ So we need to copy to ExWRAM.
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #2
|
||||
lsl r2, r2, #24 @ r2= 0x02000000
|
||||
ldr r3, =__end__ @ last ewram address
|
||||
sub r3, r2 @ r3= actual binary size
|
||||
mov r6, r2 @ r6= 0x02000000
|
||||
lsl r1, r2, #2 @ r1= 0x08000000
|
||||
|
||||
bl CopyMem
|
||||
|
||||
bx r6 @ Jump to the code to execute
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
DoEWRAMClear: @ Clear External WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r1, #0x40
|
||||
lsl r1, #12 @ r1 = 0x40000
|
||||
lsl r0, r1, #7 @ r0 = 0x2000000
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear BSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__bss_start
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear SBSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__sbss_start
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__data_lma
|
||||
ldr r2, =__data_start
|
||||
ldr r4, =__data_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1,= __iwram_lma
|
||||
ldr r2,= __iwram_start
|
||||
ldr r4,= __iwram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r2,= __load_stop_iwram0
|
||||
ldr r1,= __load_start_iwram0
|
||||
sub r3, r2, r1 @ Is there any data to copy?
|
||||
beq CIW0Skip @ no
|
||||
|
||||
ldr r2,= __iwram_overlay_start
|
||||
bl CopyMem
|
||||
@---------------------------------------------------------------------------------
|
||||
CIW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__ewram_lma
|
||||
ldr r2, =__ewram_start
|
||||
ldr r4, =__ewram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CEW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ set heap end
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =fake_heap_end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Jump to user code
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3,=main
|
||||
bx r3
|
||||
nop @ This nop is here to allow unmapped memory to be used as
|
||||
@ as a delay of almost 1 sec with a 1 cycle resolution.
|
||||
@ Read this for technical info:
|
||||
@ http://www.devrs.com/gba/files/gbadevfaqs.php#RepeatUses
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2,#3 @ These commands are used in cases where
|
||||
add r1,r2 @ the length is not a multiple of 4,
|
||||
bic r1,r2 @ even though it should be.
|
||||
|
||||
beq ClearMX @ Length is zero so exit
|
||||
|
||||
mov r2,#0
|
||||
@---------------------------------------------------------------------------------
|
||||
ClrLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
stmia r0!, {r2}
|
||||
sub r1,#4
|
||||
bne ClrLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMX:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemChk:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r0 @ the length is not a multiple of 4,
|
||||
bic r3, r0 @ even though it should be.
|
||||
beq CIDExit @ Length is zero so exit
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
sub r3, #4
|
||||
bne CIDLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDExit:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
|
||||
@ (c) 2006 by devkitPro (http://www.devkitpro.org)
|
||||
|
||||
|
||||
.section ".init"
|
||||
.global _start
|
||||
.align
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
b rom_header_end
|
||||
|
||||
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
|
||||
.fill 16,1,0 @ Game Title
|
||||
.byte 0x30,0x31 @ Maker Code (80000B0h)
|
||||
.byte 0x96 @ Fixed Value (80000B2h)
|
||||
.byte 0x00 @ Main Unit Code (80000B3h)
|
||||
.byte 0x00 @ Device Type (80000B4h)
|
||||
.fill 7,1,0 @ unused
|
||||
.byte 0x00 @ Software Version No (80000BCh)
|
||||
.byte 0xf0 @ Complement Check (80000BDh)
|
||||
.byte 0x00,0x00 @ Checksum (80000BEh)
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
rom_header_end:
|
||||
@---------------------------------------------------------------------------------
|
||||
b start_vector @ This branch must be here for proper
|
||||
@ positioning of the following header.
|
||||
|
||||
.GLOBAL __boot_method, __slave_number
|
||||
@---------------------------------------------------------------------------------
|
||||
__boot_method:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
|
||||
@---------------------------------------------------------------------------------
|
||||
__slave_number:
|
||||
@---------------------------------------------------------------------------------
|
||||
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
|
||||
|
||||
.byte 0 @ reserved
|
||||
.byte 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
.word 0 @ reserved
|
||||
|
||||
.global start_vector
|
||||
.align
|
||||
@---------------------------------------------------------------------------------
|
||||
start_vector:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x4000000 @ REG_BASE
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
mov r0, #0x1f @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Enter Thumb mode
|
||||
@---------------------------------------------------------------------------------
|
||||
add r0, pc, #1
|
||||
bx r0
|
||||
|
||||
.thumb
|
||||
|
||||
ldr r0, =__text_start
|
||||
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
|
||||
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
|
||||
|
||||
mov r0, pc
|
||||
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
|
||||
bcc SkipEWRAMClear @ No, so no need to do a copy.
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ We were started in ROM, silly emulators. :P
|
||||
@ So we need to copy to ExWRAM.
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #2
|
||||
lsl r2, r2, #24 @ r2= 0x02000000
|
||||
ldr r3, =__end__ @ last ewram address
|
||||
sub r3, r2 @ r3= actual binary size
|
||||
mov r6, r2 @ r6= 0x02000000
|
||||
lsl r1, r2, #2 @ r1= 0x08000000
|
||||
|
||||
bl CopyMem
|
||||
|
||||
bx r6 @ Jump to the code to execute
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
DoEWRAMClear: @ Clear External WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r1, #0x40
|
||||
lsl r1, #12 @ r1 = 0x40000
|
||||
lsl r0, r1, #7 @ r0 = 0x2000000
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear BSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__bss_start
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear SBSS section to 0x00
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r0, =__sbss_start
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r0
|
||||
bl ClearMem
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__data_lma
|
||||
ldr r2, =__data_start
|
||||
ldr r4, =__data_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1,= __iwram_lma
|
||||
ldr r2,= __iwram_start
|
||||
ldr r4,= __iwram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r2,= __load_stop_iwram0
|
||||
ldr r1,= __load_start_iwram0
|
||||
sub r3, r2, r1 @ Is there any data to copy?
|
||||
beq CIW0Skip @ no
|
||||
|
||||
ldr r2,= __iwram_overlay_start
|
||||
bl CopyMem
|
||||
@---------------------------------------------------------------------------------
|
||||
CIW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =__ewram_lma
|
||||
ldr r2, =__ewram_start
|
||||
ldr r4, =__ewram_end
|
||||
bl CopyMemChk
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CEW0Skip:
|
||||
@---------------------------------------------------------------------------------
|
||||
@ set heap end
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =fake_heap_end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Jump to user code
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3,=main
|
||||
bx r3
|
||||
nop @ This nop is here to allow unmapped memory to be used as
|
||||
@ as a delay of almost 1 sec with a 1 cycle resolution.
|
||||
@ Read this for technical info:
|
||||
@ http://www.devrs.com/gba/files/gbadevfaqs.php#RepeatUses
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2,#3 @ These commands are used in cases where
|
||||
add r1,r2 @ the length is not a multiple of 4,
|
||||
bic r1,r2 @ even though it should be.
|
||||
|
||||
beq ClearMX @ Length is zero so exit
|
||||
|
||||
mov r2,#0
|
||||
@---------------------------------------------------------------------------------
|
||||
ClrLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
stmia r0!, {r2}
|
||||
sub r1,#4
|
||||
bne ClrLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMX:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemChk:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@---------------------------------------------------------------------------------
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r0 @ the length is not a multiple of 4,
|
||||
bic r3, r0 @ even though it should be.
|
||||
beq CIDExit @ Length is zero so exit
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDLoop:
|
||||
@---------------------------------------------------------------------------------
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
sub r3, #4
|
||||
bne CIDLoop
|
||||
@---------------------------------------------------------------------------------
|
||||
CIDExit:
|
||||
@---------------------------------------------------------------------------------
|
||||
bx lr
|
||||
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
468
rtl/nds/prt09.as
468
rtl/nds/prt09.as
@ -1,234 +1,234 @@
|
||||
@---------------------------------------------------------------------------------
|
||||
.section ".init"
|
||||
.global _start
|
||||
@---------------------------------------------------------------------------------
|
||||
.align 4
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x04000000 @ IME = 0;
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ turn the power on for M3
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =0x8203
|
||||
add r0,r0,#0x304
|
||||
strh r1, [r0]
|
||||
|
||||
ldr r1, =0x00002078 @ disable TCM and protection unit
|
||||
mcr p15, 0, r1, c1, c0
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Protection Unit Setup added by Sasq
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Disable cache
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c5, 0 @ Instruction cache
|
||||
mcr p15, 0, r0, c7, c6, 0 @ Data cache
|
||||
|
||||
@ Wait for write buffer to empty
|
||||
mcr p15, 0, r0, c7, c10, 4
|
||||
|
||||
ldr r0, =__dtcm_start
|
||||
orr r0,r0,#0x0a
|
||||
mcr p15, 0, r0, c9, c1,0 @ DTCM base = __dtcm_start, size = 16 KB
|
||||
|
||||
mov r0,#0x20
|
||||
mcr p15, 0, r0, c9, c1,1 @ ITCM base = 0 , size = 32 MB
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Setup memory regions similar to Release Version
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 0 - IO registers
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b11001 << 1) | 0x04000000 | 1)
|
||||
mcr p15, 0, r0, c6, c0, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 1 - Main Memory
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b10101 << 1) | 0x02000000 | 1)
|
||||
mcr p15, 0, r0, c6, c1, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 2 - iwram
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b01110 << 1) | 0x037F8000 | 1)
|
||||
mcr p15, 0, r0, c6, c2, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 3 - DS Accessory (GBA Cart)
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b11010 << 1) | 0x08000000 | 1)
|
||||
mcr p15, 0, r0, c6, c3, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 4 - DTCM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=__dtcm_start
|
||||
orr r0,r0,#((0b01101 << 1) | 1)
|
||||
mcr p15, 0, r0, c6, c4, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 5 - ITCM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=__itcm_start
|
||||
orr r0,r0,#((0b01110 << 1) | 1)
|
||||
mcr p15, 0, r0, c6, c5, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 6 - System ROM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b01110 << 1) | 0xFFFF0000 | 1)
|
||||
mcr p15, 0, r0, c6, c6, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 7 - non cacheable main ram
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b10101 << 1) | 0x02400000 | 1)
|
||||
mcr p15, 0, r0, c6, c7, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Write buffer enable
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0b00000110
|
||||
mcr p15, 0, r0, c3, c0, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ DCache & ICache enable
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0b01000010
|
||||
|
||||
mcr p15, 0, r0, c2, c0, 0
|
||||
mcr p15, 0, r0, c2, c0, 1
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ IAccess
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0x36636333
|
||||
mcr p15, 0, r0, c5, c0, 3
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ DAccess
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0x36333333
|
||||
mcr p15, 0, r0, c5, c0, 2
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Enable ICache, DCache, ITCM & DTCM
|
||||
@-------------------------------------------------------------------------
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
ldr r1,= (1<<18) | (1<<16) | (1<<12) | (1<<2) | (1<<0)
|
||||
orr r0,r0,r1
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
|
||||
mov r0, #0x13 @ Switch to SVC Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_svc @ Set SVC stack
|
||||
|
||||
mov r0, #0x1F @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
ldr r1, =__itcm_lma @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
|
||||
ldr r2, =__itcm_start
|
||||
ldr r4, =__itcm_end
|
||||
bl CopyMemCheck
|
||||
|
||||
ldr r1, =__dtcm_lma @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
|
||||
ldr r2, =__dtcm_start
|
||||
ldr r4, =__dtcm_end
|
||||
bl CopyMemCheck
|
||||
|
||||
ldr r0, =__bss_start @ Clear BSS section
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r1, r0
|
||||
bl ClearMem
|
||||
|
||||
ldr r0, =__sbss_start @ Clear SBSS section
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r1, r0
|
||||
bl ClearMem
|
||||
|
||||
ldr r1, =fake_heap_end @ set heap end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3, =main
|
||||
bx r3
|
||||
nop
|
||||
|
||||
@ If the user ever returns, go to an infinte loop
|
||||
ldr r0, =ILoop
|
||||
ldr r0, [r0]
|
||||
ldr r1, =0x027FFE78
|
||||
str r0, [r1]
|
||||
bx r1
|
||||
ILoop:
|
||||
b ILoop
|
||||
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #3 @ Round down to nearest word boundary
|
||||
add r1, r1, r2 @ Shouldn't be needed
|
||||
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
|
||||
bxeq lr @ Quit if copy size is 0
|
||||
|
||||
mov r2, #0
|
||||
ClrLoop:
|
||||
stmia r0!, {r2}
|
||||
subs r1, r1, #4
|
||||
bne ClrLoop
|
||||
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemCheck:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r3, r0 @ the length is not a multiple of 4,
|
||||
bics r3, r3, r0 @ even though it should be.
|
||||
bxeq lr @ Length is zero, so exit
|
||||
CIDLoop:
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
subs r3, r3, #4
|
||||
bne CIDLoop
|
||||
|
||||
bx lr
|
||||
@---------------------------------------------------------------------------------
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
@---------------------------------------------------------------------------------
|
||||
@---------------------------------------------------------------------------------
|
||||
.section ".init"
|
||||
.global _start
|
||||
@---------------------------------------------------------------------------------
|
||||
.align 4
|
||||
.arm
|
||||
@---------------------------------------------------------------------------------
|
||||
_start:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #0x04000000 @ IME = 0;
|
||||
str r0, [r0, #0x208]
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ turn the power on for M3
|
||||
@---------------------------------------------------------------------------------
|
||||
ldr r1, =0x8203
|
||||
add r0,r0,#0x304
|
||||
strh r1, [r0]
|
||||
|
||||
ldr r1, =0x00002078 @ disable TCM and protection unit
|
||||
mcr p15, 0, r1, c1, c0
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Protection Unit Setup added by Sasq
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Disable cache
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c5, 0 @ Instruction cache
|
||||
mcr p15, 0, r0, c7, c6, 0 @ Data cache
|
||||
|
||||
@ Wait for write buffer to empty
|
||||
mcr p15, 0, r0, c7, c10, 4
|
||||
|
||||
ldr r0, =__dtcm_start
|
||||
orr r0,r0,#0x0a
|
||||
mcr p15, 0, r0, c9, c1,0 @ DTCM base = __dtcm_start, size = 16 KB
|
||||
|
||||
mov r0,#0x20
|
||||
mcr p15, 0, r0, c9, c1,1 @ ITCM base = 0 , size = 32 MB
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Setup memory regions similar to Release Version
|
||||
@---------------------------------------------------------------------------------
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 0 - IO registers
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b11001 << 1) | 0x04000000 | 1)
|
||||
mcr p15, 0, r0, c6, c0, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 1 - Main Memory
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b10101 << 1) | 0x02000000 | 1)
|
||||
mcr p15, 0, r0, c6, c1, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 2 - iwram
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b01110 << 1) | 0x037F8000 | 1)
|
||||
mcr p15, 0, r0, c6, c2, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 3 - DS Accessory (GBA Cart)
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b11010 << 1) | 0x08000000 | 1)
|
||||
mcr p15, 0, r0, c6, c3, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 4 - DTCM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=__dtcm_start
|
||||
orr r0,r0,#((0b01101 << 1) | 1)
|
||||
mcr p15, 0, r0, c6, c4, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 5 - ITCM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=__itcm_start
|
||||
orr r0,r0,#((0b01110 << 1) | 1)
|
||||
mcr p15, 0, r0, c6, c5, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 6 - System ROM
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b01110 << 1) | 0xFFFF0000 | 1)
|
||||
mcr p15, 0, r0, c6, c6, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Region 7 - non cacheable main ram
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=( (0b10101 << 1) | 0x02400000 | 1)
|
||||
mcr p15, 0, r0, c6, c7, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Write buffer enable
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0b00000110
|
||||
mcr p15, 0, r0, c3, c0, 0
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ DCache & ICache enable
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0b01000010
|
||||
|
||||
mcr p15, 0, r0, c2, c0, 0
|
||||
mcr p15, 0, r0, c2, c0, 1
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ IAccess
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0x36636333
|
||||
mcr p15, 0, r0, c5, c0, 3
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ DAccess
|
||||
@-------------------------------------------------------------------------
|
||||
ldr r0,=0x36333333
|
||||
mcr p15, 0, r0, c5, c0, 2
|
||||
|
||||
@-------------------------------------------------------------------------
|
||||
@ Enable ICache, DCache, ITCM & DTCM
|
||||
@-------------------------------------------------------------------------
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
ldr r1,= (1<<18) | (1<<16) | (1<<12) | (1<<2) | (1<<0)
|
||||
orr r0,r0,r1
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
mov r0, #0x12 @ Switch to IRQ Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_irq @ Set IRQ stack
|
||||
|
||||
mov r0, #0x13 @ Switch to SVC Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_svc @ Set SVC stack
|
||||
|
||||
mov r0, #0x1F @ Switch to System Mode
|
||||
msr cpsr, r0
|
||||
ldr sp, =__sp_usr @ Set user stack
|
||||
|
||||
ldr r1, =__itcm_lma @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
|
||||
ldr r2, =__itcm_start
|
||||
ldr r4, =__itcm_end
|
||||
bl CopyMemCheck
|
||||
|
||||
ldr r1, =__dtcm_lma @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
|
||||
ldr r2, =__dtcm_start
|
||||
ldr r4, =__dtcm_end
|
||||
bl CopyMemCheck
|
||||
|
||||
ldr r0, =__bss_start @ Clear BSS section
|
||||
ldr r1, =__bss_end
|
||||
sub r1, r1, r0
|
||||
bl ClearMem
|
||||
|
||||
ldr r0, =__sbss_start @ Clear SBSS section
|
||||
ldr r1, =__sbss_end
|
||||
sub r1, r1, r0
|
||||
bl ClearMem
|
||||
|
||||
ldr r1, =fake_heap_end @ set heap end
|
||||
ldr r0, =__eheap_end
|
||||
str r0, [r1]
|
||||
|
||||
mov r0, #0 @ int argc
|
||||
mov r1, #0 @ char *argv[]
|
||||
ldr r3, =main
|
||||
bx r3
|
||||
nop
|
||||
|
||||
@ If the user ever returns, go to an infinte loop
|
||||
ldr r0, =ILoop
|
||||
ldr r0, [r0]
|
||||
ldr r1, =0x027FFE78
|
||||
str r0, [r1]
|
||||
bx r1
|
||||
ILoop:
|
||||
b ILoop
|
||||
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Clear memory to 0x00 if length != 0
|
||||
@ r0 = Start Address
|
||||
@ r1 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
ClearMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r2, #3 @ Round down to nearest word boundary
|
||||
add r1, r1, r2 @ Shouldn't be needed
|
||||
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
|
||||
bxeq lr @ Quit if copy size is 0
|
||||
|
||||
mov r2, #0
|
||||
ClrLoop:
|
||||
stmia r0!, {r2}
|
||||
subs r1, r1, #4
|
||||
bne ClrLoop
|
||||
|
||||
bx lr
|
||||
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory if length != 0
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r4 = Dest Address + Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMemCheck:
|
||||
@---------------------------------------------------------------------------------
|
||||
sub r3, r4, r2 @ Is there any data to copy?
|
||||
@---------------------------------------------------------------------------------
|
||||
@ Copy memory
|
||||
@ r1 = Source Address
|
||||
@ r2 = Dest Address
|
||||
@ r3 = Length
|
||||
@---------------------------------------------------------------------------------
|
||||
CopyMem:
|
||||
@---------------------------------------------------------------------------------
|
||||
mov r0, #3 @ These commands are used in cases where
|
||||
add r3, r3, r0 @ the length is not a multiple of 4,
|
||||
bics r3, r3, r0 @ even though it should be.
|
||||
bxeq lr @ Length is zero, so exit
|
||||
CIDLoop:
|
||||
ldmia r1!, {r0}
|
||||
stmia r2!, {r0}
|
||||
subs r3, r3, #4
|
||||
bne CIDLoop
|
||||
|
||||
bx lr
|
||||
@---------------------------------------------------------------------------------
|
||||
.align
|
||||
.pool
|
||||
.end
|
||||
@---------------------------------------------------------------------------------
|
||||
|
@ -1,163 +1,163 @@
|
||||
#
|
||||
# $Id: prt0.as,v 1.2 2004/01/04 01:13:23 marco Exp $
|
||||
# This file is part of the Free Pascal run time library.
|
||||
# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
|
||||
# and Peter Vreman
|
||||
# members of the Free Pascal development team.
|
||||
#
|
||||
# See the file COPYING.FPC, included in this distribution,
|
||||
# for details about the copyright.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY;without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
#**********************************************************************}
|
||||
#
|
||||
# NetBSD standard (static) ELF/i386 startup code for Free Pascal
|
||||
#
|
||||
|
||||
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/i386/crt0.c?rev=1.33&content-type=text/x-cvsweb-markup
|
||||
|
||||
.file "prt0.s"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.globl __progname
|
||||
|
||||
.section .rodata
|
||||
.LC0:
|
||||
.ascii "\0"
|
||||
.data
|
||||
.align 4
|
||||
.type __progname,@object
|
||||
.size __progname,4
|
||||
__progname:
|
||||
.long .LC0
|
||||
.globl __ps_strings
|
||||
.align 4
|
||||
.type __ps_strings,@object
|
||||
.size __ps_strings,4
|
||||
__ps_strings:
|
||||
.long 0
|
||||
.align 4
|
||||
___fpucw:
|
||||
.long 0x1332
|
||||
|
||||
.globl ___fpc_brk_addr /* heap management */
|
||||
.type ___fpc_brk_addr,@object
|
||||
.size ___fpc_brk_addr,4
|
||||
___fpc_brk_addr:
|
||||
.long 0
|
||||
|
||||
#APP
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.globl __start
|
||||
.globl _start
|
||||
_start:
|
||||
__start:
|
||||
pushl %ebx # ps_strings
|
||||
pushl %ecx # obj
|
||||
pushl %edx # cleanup
|
||||
movl 12(%esp),%eax
|
||||
leal 20(%esp,%eax,4),%ecx
|
||||
leal 16(%esp),%edx
|
||||
pushl %ecx
|
||||
pushl %edx
|
||||
pushl %eax
|
||||
call ___start
|
||||
|
||||
#NO_APP
|
||||
.text
|
||||
.align 4
|
||||
.globl ___start
|
||||
.type ___start,@function
|
||||
___start:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movl 16(%ebp),%eax
|
||||
movl %eax,environ
|
||||
movl %eax,U_SYSTEM_ENVP
|
||||
movl 8(%ebp),%eax
|
||||
movl %eax,U_SYSTEM_ARGC
|
||||
movl 12(%ebp),%eax
|
||||
movl %eax,U_SYSTEM_ARGV
|
||||
movl (%eax),%edx
|
||||
movl %edx,__progname
|
||||
testl %edx,%edx
|
||||
je .L2
|
||||
pushl $47
|
||||
movl __progname,%eax
|
||||
pushl %eax
|
||||
call _strrchr
|
||||
addl $8,%esp
|
||||
movl %eax,%eax
|
||||
movl %eax,__progname
|
||||
cmpl $0,__progname
|
||||
jne .L3
|
||||
movl 12(%ebp),%eax
|
||||
movl (%eax),%edx
|
||||
movl %edx,__progname
|
||||
jmp .L2
|
||||
.align 4
|
||||
.L3:
|
||||
incl __progname
|
||||
.L4:
|
||||
.L2:
|
||||
cmpl $0,28(%ebp)
|
||||
je .L5
|
||||
movl 28(%ebp),%eax
|
||||
movl %eax,__ps_strings
|
||||
.L5:
|
||||
# pushl $_fini
|
||||
# call atexit
|
||||
# addl $4,%esp
|
||||
# call _init
|
||||
# copied from linux
|
||||
|
||||
finit /* initialize fpu */
|
||||
fwait
|
||||
fldcw ___fpucw
|
||||
|
||||
xorl %ebp,%ebp
|
||||
|
||||
call _main
|
||||
pushl %eax
|
||||
jmp _haltproc
|
||||
|
||||
.p2align 2,0x90
|
||||
.globl _haltproc
|
||||
.type _haltproc,@function
|
||||
|
||||
_haltproc:
|
||||
mov $1,%eax
|
||||
movzwl U_SYSTEM_EXITCODE,%ebx
|
||||
pushl %ebx
|
||||
call _actualsyscall
|
||||
addl $4,%esp
|
||||
jmp _haltproc
|
||||
|
||||
_actualsyscall:
|
||||
int $0x80
|
||||
jb .LErrorcode
|
||||
xor %ebx,%ebx
|
||||
ret
|
||||
.LErrorcode:
|
||||
mov %eax,%ebx
|
||||
mov $-1,%eax
|
||||
ret
|
||||
.p2align 2,0x90
|
||||
|
||||
# This section is needed for NetBSD to recognize a NetBSD binary as such.
|
||||
# otherwise it will be startup in Linux emulation mode.
|
||||
|
||||
.section ".note.netbsd.ident","a"
|
||||
.p2align 2
|
||||
|
||||
.long 7
|
||||
.long 4
|
||||
# ELF NOTE TYPE NETBSD TAG
|
||||
.long 1
|
||||
.ascii "NetBSD\0\0"
|
||||
.long 199905
|
||||
#
|
||||
# $Id: prt0.as,v 1.2 2004/01/04 01:13:23 marco Exp $
|
||||
# This file is part of the Free Pascal run time library.
|
||||
# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
|
||||
# and Peter Vreman
|
||||
# members of the Free Pascal development team.
|
||||
#
|
||||
# See the file COPYING.FPC, included in this distribution,
|
||||
# for details about the copyright.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY;without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
#**********************************************************************}
|
||||
#
|
||||
# NetBSD standard (static) ELF/i386 startup code for Free Pascal
|
||||
#
|
||||
|
||||
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/i386/crt0.c?rev=1.33&content-type=text/x-cvsweb-markup
|
||||
|
||||
.file "prt0.s"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.globl __progname
|
||||
|
||||
.section .rodata
|
||||
.LC0:
|
||||
.ascii "\0"
|
||||
.data
|
||||
.align 4
|
||||
.type __progname,@object
|
||||
.size __progname,4
|
||||
__progname:
|
||||
.long .LC0
|
||||
.globl __ps_strings
|
||||
.align 4
|
||||
.type __ps_strings,@object
|
||||
.size __ps_strings,4
|
||||
__ps_strings:
|
||||
.long 0
|
||||
.align 4
|
||||
___fpucw:
|
||||
.long 0x1332
|
||||
|
||||
.globl ___fpc_brk_addr /* heap management */
|
||||
.type ___fpc_brk_addr,@object
|
||||
.size ___fpc_brk_addr,4
|
||||
___fpc_brk_addr:
|
||||
.long 0
|
||||
|
||||
#APP
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.globl __start
|
||||
.globl _start
|
||||
_start:
|
||||
__start:
|
||||
pushl %ebx # ps_strings
|
||||
pushl %ecx # obj
|
||||
pushl %edx # cleanup
|
||||
movl 12(%esp),%eax
|
||||
leal 20(%esp,%eax,4),%ecx
|
||||
leal 16(%esp),%edx
|
||||
pushl %ecx
|
||||
pushl %edx
|
||||
pushl %eax
|
||||
call ___start
|
||||
|
||||
#NO_APP
|
||||
.text
|
||||
.align 4
|
||||
.globl ___start
|
||||
.type ___start,@function
|
||||
___start:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movl 16(%ebp),%eax
|
||||
movl %eax,environ
|
||||
movl %eax,U_SYSTEM_ENVP
|
||||
movl 8(%ebp),%eax
|
||||
movl %eax,U_SYSTEM_ARGC
|
||||
movl 12(%ebp),%eax
|
||||
movl %eax,U_SYSTEM_ARGV
|
||||
movl (%eax),%edx
|
||||
movl %edx,__progname
|
||||
testl %edx,%edx
|
||||
je .L2
|
||||
pushl $47
|
||||
movl __progname,%eax
|
||||
pushl %eax
|
||||
call _strrchr
|
||||
addl $8,%esp
|
||||
movl %eax,%eax
|
||||
movl %eax,__progname
|
||||
cmpl $0,__progname
|
||||
jne .L3
|
||||
movl 12(%ebp),%eax
|
||||
movl (%eax),%edx
|
||||
movl %edx,__progname
|
||||
jmp .L2
|
||||
.align 4
|
||||
.L3:
|
||||
incl __progname
|
||||
.L4:
|
||||
.L2:
|
||||
cmpl $0,28(%ebp)
|
||||
je .L5
|
||||
movl 28(%ebp),%eax
|
||||
movl %eax,__ps_strings
|
||||
.L5:
|
||||
# pushl $_fini
|
||||
# call atexit
|
||||
# addl $4,%esp
|
||||
# call _init
|
||||
# copied from linux
|
||||
|
||||
finit /* initialize fpu */
|
||||
fwait
|
||||
fldcw ___fpucw
|
||||
|
||||
xorl %ebp,%ebp
|
||||
|
||||
call _main
|
||||
pushl %eax
|
||||
jmp _haltproc
|
||||
|
||||
.p2align 2,0x90
|
||||
.globl _haltproc
|
||||
.type _haltproc,@function
|
||||
|
||||
_haltproc:
|
||||
mov $1,%eax
|
||||
movzwl U_SYSTEM_EXITCODE,%ebx
|
||||
pushl %ebx
|
||||
call _actualsyscall
|
||||
addl $4,%esp
|
||||
jmp _haltproc
|
||||
|
||||
_actualsyscall:
|
||||
int $0x80
|
||||
jb .LErrorcode
|
||||
xor %ebx,%ebx
|
||||
ret
|
||||
.LErrorcode:
|
||||
mov %eax,%ebx
|
||||
mov $-1,%eax
|
||||
ret
|
||||
.p2align 2,0x90
|
||||
|
||||
# This section is needed for NetBSD to recognize a NetBSD binary as such.
|
||||
# otherwise it will be startup in Linux emulation mode.
|
||||
|
||||
.section ".note.netbsd.ident","a"
|
||||
.p2align 2
|
||||
|
||||
.long 7
|
||||
.long 4
|
||||
# ELF NOTE TYPE NETBSD TAG
|
||||
.long 1
|
||||
.ascii "NetBSD\0\0"
|
||||
.long 199905
|
||||
|
@ -1,76 +1,76 @@
|
||||
// DLL Startup code for WIN32 port of Free Pascal
|
||||
// Written by P.Ozerski 16.10.1998
|
||||
.text
|
||||
.globl _mainCRTStartup
|
||||
_mainCRTStartup:
|
||||
movb $1,U_SYSTEM_ISCONSOLE
|
||||
jmp .LDLL_Entry
|
||||
.globl _WinMainCRTStartup
|
||||
_WinMainCRTStartup:
|
||||
movb $0,U_SYSTEM_ISCONSOLE
|
||||
.LDLL_Entry:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 8(%ebp),%edi
|
||||
movl %edi,SysInstance
|
||||
movl 12(%ebp),%edi
|
||||
movl %edi,U_SYSTEM_DLLREASON
|
||||
movl 16(%ebp),%edi
|
||||
movl %edi,U_SYSTEM_DLLPARAM
|
||||
movl %esp,__stkptr
|
||||
call _FPC_DLL_Entry
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret $12
|
||||
|
||||
.globl asm_exit
|
||||
asm_exit:
|
||||
pushl %eax
|
||||
call exitprocess
|
||||
|
||||
.text
|
||||
.globl exitprocess
|
||||
exitprocess:
|
||||
jmp *.L10
|
||||
.balign 4,144
|
||||
|
||||
.text
|
||||
.balign 4,144
|
||||
|
||||
.section .idata$2
|
||||
.rva .L7
|
||||
.long 0,0
|
||||
.rva .L6
|
||||
.rva .L8
|
||||
|
||||
.section .idata$4
|
||||
.L7:
|
||||
.rva .L9
|
||||
.long 0
|
||||
|
||||
.section .idata$5
|
||||
.L8:
|
||||
|
||||
|
||||
.section .idata$5
|
||||
.L10:
|
||||
.rva .L9
|
||||
.long 0
|
||||
|
||||
.section .idata$6
|
||||
.L9:
|
||||
.short 0
|
||||
.ascii "ExitProcess\000"
|
||||
.balign 2,0
|
||||
|
||||
.section .idata$7
|
||||
.L6:
|
||||
.ascii "kernel32.dll\000"
|
||||
|
||||
.bss
|
||||
.comm __stkptr,4
|
||||
// DLL Startup code for WIN32 port of Free Pascal
|
||||
// Written by P.Ozerski 16.10.1998
|
||||
.text
|
||||
.globl _mainCRTStartup
|
||||
_mainCRTStartup:
|
||||
movb $1,U_SYSTEM_ISCONSOLE
|
||||
jmp .LDLL_Entry
|
||||
.globl _WinMainCRTStartup
|
||||
_WinMainCRTStartup:
|
||||
movb $0,U_SYSTEM_ISCONSOLE
|
||||
.LDLL_Entry:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 8(%ebp),%edi
|
||||
movl %edi,SysInstance
|
||||
movl 12(%ebp),%edi
|
||||
movl %edi,U_SYSTEM_DLLREASON
|
||||
movl 16(%ebp),%edi
|
||||
movl %edi,U_SYSTEM_DLLPARAM
|
||||
movl %esp,__stkptr
|
||||
call _FPC_DLL_Entry
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret $12
|
||||
|
||||
.globl asm_exit
|
||||
asm_exit:
|
||||
pushl %eax
|
||||
call exitprocess
|
||||
|
||||
.text
|
||||
.globl exitprocess
|
||||
exitprocess:
|
||||
jmp *.L10
|
||||
.balign 4,144
|
||||
|
||||
.text
|
||||
.balign 4,144
|
||||
|
||||
.section .idata$2
|
||||
.rva .L7
|
||||
.long 0,0
|
||||
.rva .L6
|
||||
.rva .L8
|
||||
|
||||
.section .idata$4
|
||||
.L7:
|
||||
.rva .L9
|
||||
.long 0
|
||||
|
||||
.section .idata$5
|
||||
.L8:
|
||||
|
||||
|
||||
.section .idata$5
|
||||
.L10:
|
||||
.rva .L9
|
||||
.long 0
|
||||
|
||||
.section .idata$6
|
||||
.L9:
|
||||
.short 0
|
||||
.ascii "ExitProcess\000"
|
||||
.balign 2,0
|
||||
|
||||
.section .idata$7
|
||||
.L6:
|
||||
.ascii "kernel32.dll\000"
|
||||
|
||||
.bss
|
||||
.comm __stkptr,4
|
||||
|
Loading…
Reference in New Issue
Block a user