home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / i / ikhg / h / Proc < prev    next >
Text File  |  1988-02-26  |  4KB  |  123 lines

  1.        SUBT     Useful procedure entry/exit macros => &.Hdr.Proc
  2.  
  3. OldOpt SETA     {OPT}
  4.        OPT      OptNoList+OptNoP1List
  5.  
  6.        GBLS     Proc_RegList    ; Which registers to preserve
  7.        GBLA     Proc_LocalStack ; And any ADJSP on entry/exit for local vars
  8.  
  9.        GBLL     Proc_Debug      ; Whether to dump procedure name in image
  10. Proc_Debug SETL False
  11.  
  12. ; *****************************************************************************
  13. ; *** Keep a note of local stack and register use at the routine entry      ***
  14. ; *** point so that an exit may be effected anywhere in the body without    ***
  15. ; *** remembering how many (and which) registers to destack and ADJSP.      ***
  16. ; *** Also ensures that the code entry label is word-aligned.               ***
  17. ; *****************************************************************************
  18.         MACRO
  19. $label  ENTRY   $reglist,$framesize
  20.         ALIGN
  21. Proc_RegList SETS "$reglist"
  22.  [ "$framesize" = ""
  23. Proc_LocalStack SETA 0
  24.  |
  25. Proc_LocalStack SETA $framesize
  26.  ]
  27.  [ "$label" <> ""
  28.   [ Proc_Debug
  29.         B       $label
  30.         DCB     "$label", 0
  31.         ALIGN
  32.   ]
  33. $label  ROUT
  34.  ]
  35.  [ "$Proc_RegList" = ""
  36.         Push    lr
  37.  |
  38.         Push    "$Proc_RegList, lr"
  39.  ]
  40.  [ Proc_LocalStack <> 0
  41.         SUB     sp, sp, #Proc_LocalStack
  42.  ]
  43.         MEND
  44.  
  45. ; *****************************************************************************
  46. ; *** Another entry point so we can use the same routine body. NOROUT also  ***
  47. ; *** Stacks the same registers as does the corresponding ENTRY macro       ***
  48. ; *****************************************************************************
  49.         MACRO
  50. $label  ALTENTRY
  51.         ALIGN
  52.  [ "$label" <> ""
  53.   [ Proc_Debug
  54.         B       $label
  55.         DCB     "$label", 0
  56.         ALIGN
  57.   ]
  58. $label ; NOROUT
  59.  ]
  60.  [ "$Proc_RegList" = ""
  61.         Push    lr
  62.  |
  63.         Push    "$Proc_RegList, lr"
  64.  ]
  65.  [ Proc_LocalStack <> 0
  66.         SUB     sp, sp, #Proc_LocalStack
  67.  ]
  68.         MEND
  69.  
  70. ; *****************************************************************************
  71. ; *** Exit procedure, restore stack and saved registers to values on entry  ***
  72. ; *****************************************************************************
  73.         MACRO
  74. $label  EXIT    $cond
  75. $label
  76.  [ Proc_LocalStack <> 0
  77.         ADD$cond sp, sp, #Proc_LocalStack
  78.  ]
  79.  [ "$Proc_RegList" = ""
  80.         Pull    pc,$cond
  81.  |
  82.         Pull    "$Proc_RegList, pc",$cond
  83.  ]
  84.         MEND
  85.  
  86. ; *****************************************************************************
  87. ; *** Exit procedure : restore stack and saved registers + psr to values on ***
  88. ; *** entry. No longer copes with 3um ARM bug fix (world is 2um'ised)       ***
  89. ; *****************************************************************************
  90.         MACRO
  91. $label  EXITS   $cond
  92. $label
  93.  [ Proc_LocalStack <> 0
  94.         ADD$cond sp, sp, #Proc_LocalStack
  95.  ]
  96.  [ "$Proc_RegList" = ""
  97.         Pull    pc,$cond,^
  98.  |
  99.         Pull    "$Proc_RegList, pc",$cond,^
  100.  ]
  101.         MEND
  102.  
  103. ; *****************************************************************************
  104. ; *** Restore stack and saved registers, lr to values on entry to procedure ***
  105. ; *****************************************************************************
  106.         MACRO
  107. $label  PullEnv $cond
  108. $label
  109.  [ Proc_LocalStack <> 0
  110.         ADD$cond sp, sp, #Proc_LocalStack
  111.  ]
  112.  [ "$Proc_RegList" = ""
  113.         Pull    lr, $cond
  114.  |
  115.         Pull    "$Proc_RegList, lr", $cond
  116.  ]
  117.         MEND
  118.  
  119. ; *****************************************************************************
  120.  
  121.         OPT     OldOpt
  122.         END
  123.