From a2f62187c18b4f071ffacb5ce83867816bea6f15 Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 17 Oct 2022 10:42:38 -0500 Subject: [PATCH] Change ROM build to use GNU binutils --- .gitignore | 1 + build_rom.sh | 5 ++- rom.68k | 88 +++++++++++++++++++------------------- rom.bin | Bin 172 -> 176 bytes rom.elf | Bin 0 -> 920 bytes rom.ld | 5 +++ rom.lst | 116 --------------------------------------------------- 7 files changed, 54 insertions(+), 161 deletions(-) mode change 100644 => 100755 build_rom.sh mode change 100644 => 100755 rom.bin create mode 100755 rom.elf create mode 100644 rom.ld delete mode 100644 rom.lst diff --git a/.gitignore b/.gitignore index ea8c4bf..4e1aa34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.o diff --git a/build_rom.sh b/build_rom.sh old mode 100644 new mode 100755 index a7d3b32..c2181c2 --- a/build_rom.sh +++ b/build_rom.sh @@ -1,2 +1,5 @@ -vasmm68k_std rom.68k -o rom.bin -Fbin +#! /bin/bash -x +m68k-elf-as -m68010 --register-prefix-optional -o rom.o rom.68k +m68k-elf-ld -z max-page-size=1 -T rom.ld -o rom.elf rom.o +m68k-elf-objcopy -O binary rom.elf rom.bin diff --git a/rom.68k b/rom.68k index af65d2b..55d228b 100644 --- a/rom.68k +++ b/rom.68k @@ -1,77 +1,77 @@ .long 0, start start: move.w #fakestack, a7 - move.b #0x1, d0 ; Find the ROM card + move.b #0x1, d0 | Find the ROM card bra.b find_first_card romfindret: - move.l a0, a6 ; Save the ROM card IO base in a6 for later - lea (0xEE, a6), a7 ; Set up the stack at the end of the ROM's IO space RAM - bsr.b find_largest_ram ; Find the largest RAM card and put the IO base in a5 + move.l a0, a6 | Save the ROM card IO base in a6 for later + lea (0xEE, a6), a7 | Set up the stack at the end of the ROM's IO space RAM + bsr.b find_largest_ram | Find the largest RAM card and put the IO base in a5 move.l a0, a5 move.l d0, d7 - move.b #0x4, d0 ; Find a storage card and put the IO base in a4 + move.b #0x4, d0 | Find a storage card and put the IO base in a4 bsr.b find_first_card move.l a0, a4 - ; Transfer the bootsector load code to the ROM's - ; 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, 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 + | Transfer the bootsector load code to the ROM's + | 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, 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 ramcode_loop: - 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 - jmp (a6) ; Jump to the ramcode + 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 + jmp (a6) | Jump to the ramcode stop #0x2700 ramcode: - move.b #0x0, (0xFE, a6) ; Disable the ROM - move.l #0x1, (a5) ; Enable the RAM at base 0x0 + move.b #0x0, (0xFE, a6) | Disable the ROM + move.l #0x1, (a5) | Enable the RAM at base 0x0 move.l d7, a7 - ; Load sector 0 to 0x0 - move.l #0x0, (a4) ; Set the sector number to 0 - ; Transfer 0x100 (256) bytes from the storage card's data register to 0x0 - move.w #0x0, a1 ; Load a1, the destination address register, with 0x0 - move.w #0xFF, d0 ; Load d0 with the sector size - 1. + | Load sector 0 to 0x0 + move.l #0x0, (a4) | Set the sector number to 0 + | Transfer 0x100 (256) bytes from the storage card's data register to 0x0 + move.w #0x0, a1 | Load a1, the destination address register, with 0x0 + move.w #0xFF, d0 | Load d0 with the sector size - 1. sector_loop: - move.b (4, a4), (a1)+ ; Transfer a byte of sector data to the destination - dbra d0, sector_loop ; Loop back if there is more to transfer - jmp (0x0).W ; Jump to the loaded sector + move.b (4, a4), (a1)+ | Transfer a byte of sector data to the destination + dbra d0, sector_loop | Loop back if there is more to transfer + jmp (0x0).W | Jump to the loaded sector stop #0x2700 ramcode_end: -; Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found -; Clobbers d1 +| Finds the first card with the type in d0.b, and returns it's IO base address in a0, or 0 if not found +| Clobbers d1 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: - lea (0x100,a0), a0 ; adda.l #$100,a0 ; Move to the next card - move.b (0xff, a0), d1 ; Load the type of the card into d1 - beq.b ffc_done ; If the type is 0 (empty slot), we have scanned all cards, so exit the loop - cmp.b d0, d1 ; If the card is the type we want, return with the address in a0 + lea (0x100,a0), a0 | adda.l #$100,a0 ; Move to the next card + move.b (0xff, a0), d1 | Load the type of the card into d1 + beq.b ffc_done | If the type is 0 (empty slot), we have scanned all cards, so exit the loop + cmp.b d0, d1 | If the card is the type we want, return with the address in a0 beq.b ffc_done - bra.b ffc_loop ; Loop back and check the next card + bra.b ffc_loop | Loop back and check the next card ffc_done: rts -; 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 +| 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: - 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.l #0xff0000, a1 ; a1 holds the address of the current card + 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.l #0xff0000, a1 | a1 holds the address of the current card flr_loop: - lea (0x100,a1), a1 ; adda.l #$100,a0 ; Move to the next card - move.b (0xff, a1), d1 ; Load the type of the card into d1 - beq.b flr_done ; If the type is 0 (empty slot), we have scanned all cards, so exit the loop - cmp.b #0x2, d1 ; If the card isn't a RAM card, skip it + lea (0x100,a1), a1 | adda.l #$100,a0 ; Move to the next card + move.b (0xff, a1), d1 | Load the type of the card into d1 + beq.b flr_done | If the type is 0 (empty slot), we have scanned all cards, so exit the loop + cmp.b #0x2, d1 | If the card isn't a RAM card, skip it bne.b flr_loop - move.l (0x4, a1), d1 ; Load the card's size into d1 - cmp.l d0, d1 ; If the current size is less than the largest size found, go back to the start of the loop + move.l (0x4, a1), d1 | Load the card's size into d1 + cmp.l d0, d1 | If the current size is less than the largest size found, go back to the start of the loop ble.b flr_loop - move.l d1, d0 ; Store the sise and address of the new latgest card in s0 and a0 + move.l d1, d0 | Store the sise and address of the new latgest card in s0 and a0 move.l a1, a0 - bra.b flr_loop ; Loop back and check the next card + bra.b flr_loop | Loop back and check the next card flr_done: rts fakestack: diff --git a/rom.bin b/rom.bin old mode 100644 new mode 100755 index 830090300fb7eacdd0a9d6b79ec45cb63a6887db..8d1637111fdb8f79639d1cac323ffdcd3f4b89c7 GIT binary patch delta 105 zcmZ3(xPeiN0RlMeY8ciC*f20Agz0$rzhiipn5N~S#{d*zNp#WhFtB0JnW&}4VpPMx zFfm9^&j3g()iC^LU~qoP$RMQ2@IPIIhmnCP?Sqmg1Iwm{{1*z03Z4m%{7Qkw3jqMt C_ZZj! delta 101 zcmdnMxQ0=S0RlMeY8X}s*f20Agy?wqzhiipn4;yO#{d*zNp#ZiFtB0Jny975H2LJj z5IvoVCzNU!{xdK*zhq<((q#CbF0#pnfhp~Sk|qPoriT0%3XBS#36K0rfkq1f0QKD) A1^@s6 diff --git a/rom.elf b/rom.elf new file mode 100755 index 0000000000000000000000000000000000000000..dd93dcc9fafd6aa38e2e05e8ee8572ba6116e594 GIT binary patch literal 920 zcmah|&ubG=7@S?xT0x|E=@}bq4XF8sXrpf7D3e8X5AlYX_5^uTd)wccx{i~ z{12p{^z0wt(UW-gR6$C;Nhz)~yV;nFI56*<`M!B?*~jjyyASVKwuK37l&Fiw8eo6U z%o-}})-W@fKc4IXK2VD@Q+wxbjc_>Mgw=ks(%Lw|i5D%m>R_kj-Kn)2O{_FVXjYx_ z*GHeybLWd=7I9<56Mip$)H(J0HC3##$8=i$ffAEv&M!dO$_OcN``ALchO{$#gpS=l zb#?~exu|B-_3xZ6ak_BXf*qY!mry#|i;pW-e{Bz%zo_2F(W z@t(6LCa;@?$^*rV{J&mjMDIR3j_P~XH(WsffuM|?scf;>w|Gt9r=jc0{s+}d;~tA( aFK~IA$$Zf{!c|gx$FSd1+$