Advertisement
Guest User

Untitled

a guest
Jun 20th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. ; -----------------------------------------------------------------------------
  2. ; crt0.s
  3. ; -----------------------------------------------------------------------------
  4. ;
  5. ; Startup code for cc65 (RPC8e version)
  6. ;
  7.  
  8. .export _init, _exit
  9. .import _main
  10.  
  11. .export __STARTUP__ : absolute = 1 ; Mark as startup
  12. .import __RAM_START__, __RAM_SIZE__ ; Linker generated
  13. ; FIXME: We should probe in _init to determine the actual ram size,
  14. ; instead of assuming a full 64k...
  15.  
  16. .import copydata, zerobss, initlib, donelib
  17.  
  18. .include "zeropage.inc"
  19. .bss
  20.  
  21. ; -----------------------------------------------------------------------------
  22. ; Place the startup code in a special segment.
  23.  
  24. .segment "STARTUP"
  25.  
  26. ; -----------------------------------------------------------------------------
  27. ; A little light 6502 housekeeping.
  28.  
  29. _init: ; LDX #$FF ; Initialize stack pointer to $01FF.
  30. ; TXS
  31. ; CLD ; Clear decimal mode.
  32.  
  33. ; -----------------------------------------------------------------------------
  34. ; Set cc65 argument stack pointer.
  35.  
  36. LDA #<(__RAM_START__ + __RAM_SIZE__)
  37. STA sp
  38. LDA #>(__RAM_START__ + __RAM_SIZE__)
  39. STA sp+1
  40.  
  41. ; -----------------------------------------------------------------------------
  42. ; Initialize memory storage.
  43.  
  44. ; JSR zerobss ; Clear BSS segment.
  45. ; JSR copydata ; Initialize DATA segment.
  46. ; JSR initlib ; Run constructors.
  47.  
  48. ; -----------------------------------------------------------------------------
  49. ; Call main().
  50.  
  51. JSR _main
  52.  
  53. ; -----------------------------------------------------------------------------
  54. ; Cleanup and exit.
  55.  
  56. _exit: ; JSR donelib ; Run destructors
  57. exitloop: JMP exitloop
  58. ; Do we really want to BRK here? Or ought we enter an infinite WAI
  59. ; loop instead?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement