emu/rom.lst
2022-10-09 12:14:49 -05:00

117 lines
6.9 KiB
Plaintext

Sections:
00: ".text" (0-AC)
Source: "rom.68k"
00:00000000 00000000 1: .long 0, start
00:00000004 00000008
2: start:
00:00000008 3E7C00A8 3: move.w #fakestack, a7
00:0000000C 103C0001 4: move.b #0x1, d0 ; Find the ROM card
00:00000010 6054 5: bra.b find_first_card
6: romfindret:
00:00000012 2C48 7: move.l a0, a6 ; Save the ROM card IO base in a6 for later
00:00000014 4FEE00EE 8: lea (0xEE, a6), a7 ; Set up the stack at the end of the ROM's IO space RAM
00:00000018 6164 9: bsr.b find_largest_ram ; Find the largest RAM card and put the IO base in a5
00:0000001A 2A48 10: move.l a0, a5
00:0000001C 2E00 11: move.l d0, d7
00:0000001E 103C0004 12: move.b #0x4, d0 ; Find a storage card and put the IO base in a4
00:00000022 6142 13: bsr.b find_first_card
00:00000024 2848 14: move.l a0, a4
15: ; Transfer the bootsector load code to the ROM's
16: ; built in RAM at the start of it's IO space
00:00000026 303C002A 17: move.w #(ramcode_end - ramcode), d0 ; Put the length of the ramcode in d0
00:0000002A 307C003C 18: move.w #ramcode, a0 ; Put the address of the ramcode in a0
00:0000002E 224E 19: move.l a6, a1 ; Put the start of the ROM's IO space RAM in a0
20: ramcode_loop:
00:00000030 12D8 21: move.b (a0)+, (a1)+ ; Transfer a byte of ramcode to the ROM's IO space RAM
00:00000032 51C8FFFC 22: dbra d0, ramcode_loop ; Loop back if there is more to transfer
00:00000036 4ED6 23: jmp (a6) ; Jump to the ramcode
00:00000038 4E722700 24: stop #0x2700
25:
26: ramcode:
00:0000003C 1D7C000000FE 27: move.b #0x0, (0xFE, a6) ; Disable the ROM
00:00000042 2ABC00000001 28: move.l #0x1, (a5) ; Enable the RAM at base 0x0
00:00000048 2E47 29: move.l d7, a7
30: ; Load sector 0 to 0x0
00:0000004A 28BC00000000 31: move.l #0x0, (a4) ; Set the sector number to 0
32: ; Transfer 0x100 (256) bytes from the storage card's data register to 0x0
00:00000050 93C9 33: move.w #0x0, a1 ; Load a1, the destination address register, with 0x0
00:00000052 303C00FF 34: move.w #0xFF, d0 ; Load d0 with the sector size - 1.
35: sector_loop:
00:00000056 12EC0004 36: move.b (4, a4), (a1)+ ; Transfer a byte of sector data to the destination
00:0000005A 51C8FFFA 37: dbra d0, sector_loop ; Loop back if there is more to transfer
00:0000005E 4EF80000 38: jmp (0x0).W ; Jump to the loaded sector
39:
00:00000062 4E722700 40: stop #0x2700
41: ramcode_end:
42:
43: ; Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found
44: ; Clobbers d1
45: find_first_card:
00:00000066 207C00FF0000 46: move.l #0xff0000, a0 ; a0 holds the address of the current card
47: ffc_loop:
00:0000006C 41E80100 48: lea (0x100,a0), a0 ; adda.l #$100,a0 ; Move to the next card
00:00000070 122800FF 49: move.b (0xff, a0), d1 ; Load the type of the card into d1
00:00000074 6706 50: beq.b ffc_done ; If the type is 0 (empty slot), we have scanned all cards, so exit the loop
00:00000076 B200 51: cmp.b d0, d1 ; If the card is the type we want, return with the address in a0
00:00000078 6702 52: beq.b ffc_done
00:0000007A 60F0 53: bra.b ffc_loop ; Loop back and check the next card
54: ffc_done:
00:0000007C 4E75 55: rts
56:
57: ; Finds the largest RAM card, and returns it's IO base address in a0 and size in d0, or 0 if not found
58: ; Clobbers d1, a1
59: find_largest_ram:
00:0000007E 7000 60: move.l #0x0, d0 ; d0 holds the size of the largest RAM card found
00:00000080 91C8 61: move.w #0x0, a0 ; a0 holds the address of the largest RAM card found
00:00000082 227C00FF0000 62: move.l #0xff0000, a1 ; a1 holds the address of the current card
63: flr_loop:
00:00000088 43E90100 64: lea (0x100,a1), a1 ; adda.l #$100,a0 ; Move to the next card
00:0000008C 122900FF 65: move.b (0xff, a1), d1 ; Load the type of the card into d1
00:00000090 6714 66: beq.b flr_done ; If the type is 0 (empty slot), we have scanned all cards, so exit the loop
00:00000092 B23C0002 67: cmp.b #0x2, d1 ; If the card isn't a RAM card, skip it
00:00000096 66F0 68: bne.b flr_loop
00:00000098 22290004 69: move.l (0x4, a1), d1 ; Load the card's size into d1
00:0000009C B280 70: cmp.l d0, d1 ; If the current size is less than the largest size found, go back to the start of the loop
00:0000009E 6FE8 71: ble.b flr_loop
00:000000A0 2001 72: move.l d1, d0 ; Store the sise and address of the new latgest card in s0 and a0
00:000000A2 2049 73: move.l a1, a0
00:000000A4 60E2 74: bra.b flr_loop ; Loop back and check the next card
75: flr_done:
00:000000A6 4E75 76: rts
77: fakestack:
00:000000A8 00000012 78: .long romfindret
79:
Symbols by name:
fakestack 00:000000A8
ffc_done 00:0000007C
ffc_loop 00:0000006C
find_first_card 00:00000066
find_largest_ram 00:0000007E
flr_done 00:000000A6
flr_loop 00:00000088
ramcode 00:0000003C
ramcode_end 00:00000066
ramcode_loop 00:00000030
romfindret 00:00000012
sector_loop 00:00000056
start 00:00000008
Symbols by value:
00000008 start
00000012 romfindret
00000030 ramcode_loop
0000003C ramcode
00000056 sector_loop
00000066 find_first_card
00000066 ramcode_end
0000006C ffc_loop
0000007C ffc_done
0000007E find_largest_ram
00000088 flr_loop
000000A6 flr_done
000000A8 fakestack