Advertisement
Kitomas

kit-8 std/l1_sub.h v0

Apr 13th, 2023
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | Source Code | 0 0
  1. #ifndef _STD_L1_SUB_H
  2. #define _STD_L1_SUB_H
  3. ;std/l1_sub.h
  4. #include "pseudoOps.h"
  5.  
  6. ;simple anti-clobbering single-depth subroutine technology
  7. #define L1ARG 0xea
  8. #define L1IRG 0xeb
  9. #define L1CRG 0xec
  10. #define L1RTA 0xee
  11. #define l1call_abs(_addr) /* only saves L&H */\
  12.     stc_abs(L1CRG)          /* save C (L&H) */                      &&\
  13.     ldc_imm(_addr) && jpr   /* load subroutine address && jpr */    &&\
  14.     ldc_abs(L1CRG)          /* restore C */
  15. #define l1call_abs_s(_addr) \
  16.     sta $,L1ARG                     /* save registers to L1_RG */           &&\
  17.     sti $,L1IRG                     /* ^^ */                                &&\
  18.     stc_abs(L1CRG)                  /* ^^ */                                &&\
  19.     ldc_imm(_addr) && jpr        /* load subroutine address && jpr there */ &&\
  20.     ldi #,0                         /* restore registers after returning */ &&\
  21.     lda @,L1ARG                     /* ^^ */                                &&\
  22.     ldl @,L1CRG && ldh @,1+L1CRG    /* ^^ */                                &&\
  23.     ldi @,L1IRG                     /* ^^ */                           
  24. #define l1prep stc_abs(L1RTA)       //save return address for later
  25. #define l1rts ldc_abs(L1RTA) && jpr //retrieve return address and return
  26.  
  27. #endif
Tags: kit-8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement