_kernel_format_data_var.s 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .xdef __handle_data_var_AND___kernel_format_data_var,__kernel_format_data_var_relocate,__kernel_format_data_var_cleanup_almost_end,__data_var_name_start,__ld_insert_kernel_data_refs,__ld_insert_data_var_name
  2. | This file requires cleanup code.
  3. .xdef __ref_all___complex_main
  4. | This file requires the jump table in %a5.
  5. .xdef __ref_all___optimize_rom_calls
  6. | SymFindPtr seems to require the in-use bit.
  7. .xdef __ref_all___set_file_in_use_bit
  8. .section _st95
  9. __kernel_format_data_var:
  10. | Save registers that may be destroyed.
  11. movem.l %d3-%d5,-(%sp)
  12. | Push flags for SymFindPtr.
  13. clr.l -(%sp)
  14. | Push pointer to terminating 0 byte of variable name.
  15. pea.l __ld_data_var_name_end(%pc)
  16. | Call SymFindPtr.
  17. move.l (%a5,0x283*4),%a0 /* SymFindPtr */
  18. jsr (%a0)
  19. | Test the result and put it into %d5.
  20. move.l %a0,%d5
  21. beq __kernel_format_data_var_not_found
  22. | Put the handle into %d4 and on the stack.
  23. move.w 12(%a0),%d4
  24. move.w %d4,(%sp)
  25. | Call HeapDeref on the file handle.
  26. move.l (%a5,0x96*4),%a0 /* HeapDeref */
  27. jsr (%a0)
  28. | Compare the size of the variable with the actual
  29. | data size. Add 1 for the tag byte and 5 for the
  30. | extension.
  31. cmp.w #__ld_data_size+5+1,(%a0)
  32. bne __kernel_format_data_var_corrupt
  33. | Code is inserted here to:
  34. | * put the address to use into %d3
  35. | * if the file is copied, clear %d4
  36. .section _st99
  37. | Relocate the program.
  38. __kernel_format_data_var_relocate:
  39. lea.l __ld_insert_kernel_data_refs(%pc),%a0
  40. lea.l __ld_entry_point(%pc),%a1
  41. moveq.l #0,%d1
  42. __kernel_format_data_refs_loop_1:
  43. move.w (%a0)+,%d1
  44. beq.s __kernel_format_data_refs_done_1
  45. add.l %d3,(%a1,%d1.l)
  46. bra.s __kernel_format_data_refs_loop_1
  47. __kernel_format_data_refs_done_1:
  48. .section _st1061
  49. __kernel_format_data_var_cleanup:
  50. | Unrelocate the program.
  51. lea.l __ld_insert_kernel_data_refs(%pc),%a0
  52. lea.l __ld_entry_point(%pc),%a1
  53. moveq.l #0,%d1
  54. __kernel_format_data_refs_loop_2:
  55. move.w (%a0)+,%d1
  56. beq.s __kernel_format_data_refs_done_2
  57. sub.l %d3,(%a1,%d1.l)
  58. bra.s __kernel_format_data_refs_loop_2
  59. __kernel_format_data_refs_done_2:
  60. .section _st1065
  61. __kernel_format_data_var_cleanup_almost_end:
  62. | Clean up the stack and registers.
  63. movem.l (%sp)+,%d1-%d5
  64. __kernel_format_data_var_cleanup_end:
  65. .section _st10000, "d"
  66. __ld_insert_kernel_data_refs:
  67. | The format for the data reloc table is as follows:
  68. | For each reloc...
  69. | 2 bytes: offset into the program
  70. | 2 bytes: 0
  71. .section _st10001, "d"
  72. __data_var_name_start:
  73. .byte 0
  74. __ld_insert_data_var_name: