imularm.s 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ; "asmarm.s" Copyright (C) Codemist Ltd, 1992
  2. ;
  3. ;
  4. r0 RN 0 ; r0-r3 are used as workspace here
  5. r1 RN 1
  6. r2 RN 2
  7. r3 RN 3
  8. r12 RN 12 ; points at profile_record
  9. sp RN 13 ; stack provided by the operating system for me
  10. lr RN 14 ; return address
  11. pc RN 15
  12. AREA |C$$code|, CODE, READONLY
  13. IMPORT |__main|
  14. B |__main|
  15. EXPORT |__RO_Base|
  16. EXPORT |__RO_Limit|
  17. IMPORT |Image$$RO$$Base|
  18. IMPORT |Image$$RO$$Limit|
  19. |__RO_Base|
  20. & |Image$$RO$$Base|
  21. |__RO_Limit|
  22. & |Image$$RO$$Limit|
  23. EXPORT wimp_tick
  24. IMPORT C_nil
  25. IMPORT tick_pending
  26. IMPORT polltick_pending
  27. IMPORT already_in_gc
  28. IMPORT tick_on_gc_exit
  29. IMPORT saveheaplimit
  30. IMPORT savevheaplimit
  31. IMPORT savecodelimit
  32. IMPORT savestacklimit
  33. IMPORT stackbase
  34. tick_count
  35. & 0
  36. wimp_tick
  37. LDR r2, tick_count
  38. SUBS r2, r2, #1 ; decrement tick_count
  39. MOVMI r2, #20 ; set back to 1/5 second delay on wrap
  40. STR r2, tick_count
  41. MOVPLS pc, lr ; not ready yet
  42. LDR r2, =polltick_pending
  43. STR r2, [r2, #0] ; set polltick_pending
  44. LDR r2, =tick_pending
  45. LDR r0, [r2, #0]
  46. CMPS r0, #0
  47. MOVNES pc, lr ; tick already signalled
  48. LDR r0, =already_in_gc
  49. LDR r1, [r0, #0]
  50. CMPS r1, #0
  51. BEQ not_in_gc
  52. LDR r2, =tick_on_gc_exit
  53. STR r1, [r2, #0] ; special case if garbage collecting
  54. MOVS pc, lr
  55. not_in_gc
  56. LDR r0, =C_nil ; use NIL as base-register
  57. LDR r0, [r0, #0]
  58. BIC r0, r0, #&80000000 ; clean up potential mark bit
  59. MOV r1, r0
  60. MOV r3, #1
  61. STR r3, [r2, #0]
  62. LDR r3, [r1, #76]
  63. LDR r2, =saveheaplimit
  64. STR r3, [r2, #0]
  65. LDR r2, [r1, #72]
  66. STR r2, [r1, #76]
  67. LDR r1, [r0, #80]
  68. LDR r2, =savevheaplimit
  69. STR r1, [r2, #0]
  70. LDR r1, [r0, #84]
  71. STR r1, [r0, #80]
  72. LDR r2, [r0, #56]
  73. LDR r1, =savecodelimit
  74. STR r2, [r1, #0]
  75. LDR r1, [r0, #52]
  76. STR r1, [r0, #56]
  77. LDR r2, [r0, #60]
  78. LDR r1, =savestacklimit
  79. STR r2, [r1, #0]
  80. LDR r1, =stackbase
  81. LDR r1, [r1, #0]
  82. STR r1, [r0, #60]
  83. MOVS pc, lr
  84. END