Commit c522f63f authored by Steve Revill's avatar Steve Revill
Browse files

Added FRAMLDR/FRAMSTR macros

Detail:
  These macros allow easy access to registers pushed on the stack during the Entry macro.
This is simpler than the previous method of "LDR     r1, [sp, #Proc_LocalStack + 1*4]" because the new macros will calculate the correct offset even if non-continuous regs are used, and will also trap attempts to access regs that weren't pushed onto the stack.

  The FRAMSTR macro can be used to alter the values that will be returned on EXIT.
Admin:
  Tested by looking at produced code in Zap
Notes:
  Changes by James Lampard.

Version 1.71. Tagged as 'HdrSrc-1_71'
parent 299b0082
/* (1.70) /* (1.71)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 1.70 #define Module_MajorVersion_CMHG 1.71
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 26 Jun 2009 #define Module_Date_CMHG 03 Jul 2009
#define Module_MajorVersion "1.70" #define Module_MajorVersion "1.71"
#define Module_Version 170 #define Module_Version 171
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "26 Jun 2009" #define Module_Date "03 Jul 2009"
#define Module_ApplicationDate "26-Jun-09" #define Module_ApplicationDate "03-Jul-09"
#define Module_ComponentName "HdrSrc" #define Module_ComponentName "HdrSrc"
#define Module_ComponentPath "castle/RiscOS/Sources/Programmer/HdrSrc" #define Module_ComponentPath "castle/RiscOS/Sources/Programmer/HdrSrc"
#define Module_FullVersion "1.70" #define Module_FullVersion "1.71"
#define Module_HelpVersion "1.70 (26 Jun 2009)" #define Module_HelpVersion "1.71 (03 Jul 2009)"
#define Module_LibraryVersionInfo "1:70" #define Module_LibraryVersionInfo "1:71"
...@@ -426,5 +426,119 @@ $label ...@@ -426,5 +426,119 @@ $label
; ***************************************************************************** ; *****************************************************************************
; *****************************************************************************
; *** FRAMLDR/FRAMSTR macros ***
; *** That let you access the register values stacked on Entry ***
; *** to replace LDR r1, [sp, #Proc_LocalStack + 1*4] ***
; *** ***
; *** The new macros allow non-continuous regs to be used, and will generate***
; *** an error if you try to access a register not stored on the stack ***
; *** ***
; *** FRAMLDR r0 load r0 stored on stack frame by Entry macro ***
; *** FRAMLDR r5,CS load r5 from stack frame if CS ***
; *** FRAMLDR r0,,r8 load r8 on stack frame into r0 ***
; *** FRAMLDR r0,HI,r10 load r10 on stack frame into r0 if HI ***
; *** ***
; *** A particularly useful way of using this macro is: ***
; *** FRAMSTR r8,,r0 change r0 value that will be restored on EXIT ***
; *** ...more code ***
; *** EXIT ***
; *****************************************************************************
GBLA Fram_SpecRegOffset ;offset to load/store particular reg
GBLS Fram_RegStr
GBLS Fram_CopyRegs
GBLS Fram_LowRegStr
MACRO
FRAMSPL $origvar,$newvar,$sep
$newvar SETS ""
WHILE (($origvar):CC:" ":LEFT:1 <> "$sep"):LAND:($origvar >"")
$newvar SETS $newvar:CC:($origvar:LEFT:1)
[ ($origvar >"")
$origvar SETS $origvar:RIGHT:(:LEN:$origvar-1)
]
WEND
;skip remaining seperator
[ ($origvar >"")
$origvar SETS $origvar:RIGHT:(:LEN:$origvar-1)
]
MEND
MACRO
FRAMCOM $dstreg,$framereg
LCLA actframe
LCLA counter
actframe SETA $dstreg
[ "$framereg" <>""
actframe SETA $framereg
]
LCLA regmask
Fram_CopyRegs SETS Proc_RegList
WHILE Fram_CopyRegs > ""
FRAMSPL "Fram_CopyRegs","Fram_RegStr",","
;regno =r0-r8 or a single reg r5
LCLA lowreg
LCLA highreg
FRAMSPL "Fram_RegStr","Fram_LowRegStr","-"
lowreg SETA $Fram_LowRegStr
[ Fram_RegStr =""
highreg SETA lowreg
|
highreg SETA $Fram_RegStr
]
;set bits between lowreg and highreg in our mask
WHILE lowreg <=highreg
regmask SETA regmask:OR:(1:SHL:lowreg)
lowreg SETA lowreg +1
WEND
WEND
;calculate Fram_SpecRegOffset using regmask
Fram_SpecRegOffset SETA 0
LCLA counter
WHILE counter <actframe
[ (regmask:AND:(1:SHL:counter)) >0
Fram_SpecRegOffset SETA Fram_SpecRegOffset+4
]
counter SETA counter +1
WEND
[ (regmask:AND:(1:SHL:counter)) =0
LCLS tempstr
[ actframe >9
actframe SETA actframe -10
tempstr SETS "1"
]
! 1,"r$tempstr":CC:("$actframe":RIGHT:1):CC:" not in frame!"
]
MEND
MACRO
$label FRAMLDR $dstreg,$cond,$framereg
$label FRAMCOM $dstreg,$framereg
LDR$cond $dstreg,[sp ,#Proc_RegOffset +Fram_SpecRegOffset]
MEND
MACRO
$label FRAMSTR $dstreg,$cond,$framereg
$label FRAMCOM $dstreg,$framereg
STR$cond $dstreg,[sp ,#Proc_RegOffset +Fram_SpecRegOffset]
MEND
; *****************************************************************************
OPT OldOpt OPT OldOpt
END END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment