Define explicit ABI for functions
This commit is contained in:
parent
164fdaa8f1
commit
3efad948f2
4
abi_ref
Normal file
4
abi_ref
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
d0, d1, a0, and a1 are caller preserved
|
||||||
|
d2-d7 and a2-a5 are callee preserved
|
||||||
|
a6 is frame pointer
|
||||||
|
a7 is stack pointer
|
28
rom.68k
28
rom.68k
@ -4,11 +4,11 @@ _start:
|
|||||||
move.w #0x1, d0 | Find the ROM card
|
move.w #0x1, d0 | Find the ROM card
|
||||||
bra.b find_first_card
|
bra.b find_first_card
|
||||||
romfindret:
|
romfindret:
|
||||||
move.l a0, a6 | Save the ROM card IO base in a6 for later
|
move.l a0, a2 | Save the ROM card IO base in a6 for later
|
||||||
move.l #0x10000, a7 | Set up the stack at the end of the ROM card's RAM
|
move.l #0x10000, a7 | Set up the stack at the end of the ROM card's RAM
|
||||||
bsr.w find_largest_ram | Find the largest RAM card and put the IO base in a5
|
bsr.w find_largest_ram | Find the largest RAM card and put the IO base in a3
|
||||||
move.l a0, a5
|
move.l a0, a3
|
||||||
move.l d0, d7
|
move.l d0, d2
|
||||||
move.l #0x8100, a1
|
move.l #0x8100, a1
|
||||||
bsr.w find_all_ram_cards
|
bsr.w find_all_ram_cards
|
||||||
move.l #0x8100, a0
|
move.l #0x8100, a0
|
||||||
@ -20,20 +20,20 @@ romfindret:
|
|||||||
| built in RAM at the start of it's IO space
|
| built in RAM at the start of it's IO space
|
||||||
move.w #(ramcode_end - ramcode), d0 | Put the length of the ramcode in d0
|
move.w #(ramcode_end - ramcode), d0 | Put the length of the ramcode in d0
|
||||||
move.w #ramcode, a0 | Put the address of the ramcode in a0
|
move.w #ramcode, a0 | Put the address of the ramcode in a0
|
||||||
move.l a6, a1 | Put the start of the ROM's IO space RAM in a0
|
move.l a2, a1 | Put the start of the ROM's IO space RAM in a0
|
||||||
ramcode_loop:
|
ramcode_loop:
|
||||||
move.b (a0)+, (a1)+ | Transfer a byte of ramcode to the ROM's IO space RAM
|
move.b (a0)+, (a1)+ | Transfer a byte of ramcode to the ROM's IO space RAM
|
||||||
dbra d0, ramcode_loop | Loop back if there is more to transfer
|
dbra d0, ramcode_loop | Loop back if there is more to transfer
|
||||||
jmp (a6) | Jump to the ramcode
|
jmp (a2) | Jump to the ramcode
|
||||||
|
|
||||||
ramcode:
|
ramcode:
|
||||||
move.b #0x0, (0xF3, a6) | Disable the ROM
|
move.b #0x0, (0xF3, a2) | Disable the ROM
|
||||||
move.l #0x1, (a5) | Enable the RAM at base 0x0
|
move.l #0x1, (a3) | Enable the RAM at base 0x0
|
||||||
cmpi.l #0x1000000, d7
|
cmpi.l #0x1000000, d2
|
||||||
blt.b sp_ok
|
blt.b sp_ok
|
||||||
move.l #0xff0000, d7
|
move.l #0xff0000, d2
|
||||||
sp_ok:
|
sp_ok:
|
||||||
move.l d7, a7
|
move.l d2, a7
|
||||||
| Load sector 0 to 0x0
|
| Load sector 0 to 0x0
|
||||||
move.l #0x0, (0x0, a4) | Set the sector number to 0
|
move.l #0x0, (0x0, a4) | Set the sector number to 0
|
||||||
move.l #0x1, (0x4, a4) | Set the sector count to 1
|
move.l #0x1, (0x4, a4) | Set the sector count to 1
|
||||||
@ -45,7 +45,6 @@ ramcode_end:
|
|||||||
nop | Padding to make sure ramcode_end and find_first_card are different
|
nop | Padding to make sure ramcode_end and find_first_card are different
|
||||||
|
|
||||||
| Finds the first card with the type in d0.w, and returns it's IO base address in a0, or 0 if not found
|
| Finds the first card with the type in d0.w, and returns it's IO base address in a0, or 0 if not found
|
||||||
| Clobbers d1
|
|
||||||
find_first_card:
|
find_first_card:
|
||||||
move.l #0xff0000, a0 | a0 holds the address of the current card
|
move.l #0xff0000, a0 | a0 holds the address of the current card
|
||||||
ffc_loop:
|
ffc_loop:
|
||||||
@ -59,7 +58,6 @@ ffc_done:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
| Finds the largest RAM card, and returns it's IO base address in a0 and size in d0, or 0 if not found
|
| Finds the largest RAM card, and returns it's IO base address in a0 and size in d0, or 0 if not found
|
||||||
| Clobbers d1, a1
|
|
||||||
find_largest_ram:
|
find_largest_ram:
|
||||||
move.l #0x0, d0 | d0 holds the size of the largest RAM card found
|
move.l #0x0, d0 | d0 holds the size of the largest RAM card found
|
||||||
move.w #0x0, a0 | a0 holds the address of the largest RAM card found
|
move.w #0x0, a0 | a0 holds the address of the largest RAM card found
|
||||||
@ -83,7 +81,6 @@ fakestack:
|
|||||||
|
|
||||||
| 1KB buffer in a1
|
| 1KB buffer in a1
|
||||||
| Returns list length in d0
|
| Returns list length in d0
|
||||||
| Clobbers a1, d1
|
|
||||||
find_all_ram_cards:
|
find_all_ram_cards:
|
||||||
move.b #0, d0 | d0 holds the number of RAM cards found.
|
move.b #0, d0 | d0 holds the number of RAM cards found.
|
||||||
move.l #0xff0000, a0 | a0 holds the address of the current card.
|
move.l #0xff0000, a0 | a0 holds the address of the current card.
|
||||||
@ -103,8 +100,8 @@ farc_done:
|
|||||||
| optimized bubble sort to sort RAM cards by size
|
| optimized bubble sort to sort RAM cards by size
|
||||||
| Buffer in a0
|
| Buffer in a0
|
||||||
| Length in d0
|
| Length in d0
|
||||||
| Clobbers d1, d2, d3, d4, a1, a2
|
|
||||||
sort_ram_cards:
|
sort_ram_cards:
|
||||||
|
movem.l d2-d4/a2, -(a7) | Save calle-preserved registers
|
||||||
move.b #0, d1 | d1 = newlen
|
move.b #0, d1 | d1 = newlen
|
||||||
move.b #1, d2 | d2 = i
|
move.b #1, d2 | d2 = i
|
||||||
move.l a0, a1 | a1 holds the pointer to the current pair
|
move.l a0, a1 | a1 holds the pointer to the current pair
|
||||||
@ -129,4 +126,5 @@ src_inner_loop_done:
|
|||||||
move.b d1, d0 | len = newlen
|
move.b d1, d0 | len = newlen
|
||||||
cmp #1, d0 | if n > 1, branch to outer loop
|
cmp #1, d0 | if n > 1, branch to outer loop
|
||||||
bgt.b sort_ram_cards
|
bgt.b sort_ram_cards
|
||||||
|
movem.l (a7)+, d2-d4/a2 | Restore calle-preserved registers
|
||||||
rts
|
rts
|
||||||
|
Loading…
Reference in New Issue
Block a user