Advertisement
bladamson

Untitled

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