_compressed_format_rom_calls.s 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. | Copyright (C) 2002-2003 Sebastian Reichelt.
  2. | Copyright (C) 2003 Kevin Kofler.
  3. | See License.txt for licensing conditions.
  4. .xdef __handle_rom_calls_AND___compressed_format_rom_calls_AND___nostub,__ld_insert_compressed_rom_calls
  5. | This file requires cleanup code.
  6. .xdef __ref_all___complex_main
  7. | This file requires the jump table in %a5.
  8. .xdef __ref_all___optimize_rom_calls
  9. .section _st90
  10. __compressed_format_rom_calls:
  11. | Relocate the program.
  12. lea.l __ld_insert_compressed_rom_calls(%pc),%a0
  13. lea.l __ld_compressed_rom_calls_ref-4(%pc),%a1
  14. clr.w %d2
  15. move.w #-2,-(%sp)
  16. __compressed_format_rom_calls_loop_1:
  17. move.w (%sp)+,%d1 | get the previous [ROM_CALL number]*2
  18. subq.w #2,%d1 | next ROM_CALL, the decoding function adds 2 too much
  19. bsr __decode_compressed_offset
  20. bcs.s __compressed_format_rom_calls_done_1
  21. move.w %d1,-(%sp) | we need to reuse d1 for the offsets below
  22. add.w %d1,%d1 | multiply the offset by 2, because we want 4 * num,
  23. | whereas decoding yields 2 * num
  24. move.l (%a5,%d1.w),%d0
  25. moveq.l #0,%d1
  26. __compressed_format_rom_calls_loop_2:
  27. bsr __decode_compressed_offset
  28. bcs.s __compressed_format_rom_calls_loop_1 | done with the inner loop
  29. add.l %d0,(%a1,%d1.l)
  30. bra.s __compressed_format_rom_calls_loop_2
  31. __compressed_format_rom_calls_done_1:
  32. .section _st1070
  33. __compressed_format_rom_calls_cleanup:
  34. | Unrelocate the program.
  35. lea.l __ld_insert_compressed_rom_calls(%pc),%a0
  36. lea.l __ld_compressed_rom_calls_ref-4(%pc),%a1
  37. clr.w %d2
  38. move.w #-2,-(%sp)
  39. __compressed_format_rom_calls_loop_3:
  40. move.w (%sp)+,%d1 | get the previous [ROM_CALL number]*2
  41. subq.w #2,%d1 | next ROM_CALL, the decoding function adds 2 too much
  42. bsr __decode_compressed_offset
  43. bcs.s __compressed_format_rom_calls_done_3
  44. move.w %d1,-(%sp) | we need to reuse d1 for the offsets below
  45. add.w %d1,%d1 | multiply the offset by 2, because we want 4 * num,
  46. | whereas decoding yields 2 * num
  47. move.l (%a5,%d1.w),%d0
  48. moveq.l #0,%d1
  49. __compressed_format_rom_calls_loop_4:
  50. bsr __decode_compressed_offset
  51. bcs.s __compressed_format_rom_calls_loop_3 | done with the inner loop
  52. sub.l %d0,(%a1,%d1.l)
  53. bra.s __compressed_format_rom_calls_loop_4
  54. __compressed_format_rom_calls_done_3:
  55. .section _st10000, "d"
  56. __ld_insert_compressed_rom_calls:
  57. | The format for the ROM call table is as follows:
  58. | For each ROM call used...
  59. | A compressed reloc table (see _compressed_format_relocs.s) encoding:
  60. | the offset of the ROM call number from [the last one + 1], or from 0 (base)
  61. | the actual reloc table
  62. | 1 byte: 0 (empty compressed reloc table)