Commit 1e87c8ed authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Add LDHA, LDSHA macros to HdrSrc (trunk branch)

Detail:
  Add two new macros to allow the loading of (un)signed halfwords from an array of halfwords, i.e. LDR(S)H $dest, [$array, $index, LSL #1]
  These shared macros help tidy up some code in the International & FontManager modules, code which needed to be changed to get the NoUnaligned build option working correctly.
Admin:
  Tested on rev C2 beagleboard, with and without NoUnaligned. Macros are untested for the situation where unaligned loads are supported but LDRH is not; however the code produced should be identical to the code that the International & FontManager modules originally used.


Version 1.73. Tagged as 'HdrSrc-1_73'
parent 4f610204
/* (1.72)
/* (1.73)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.72
#define Module_MajorVersion_CMHG 1.73
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Oct 2009
#define Module_Date_CMHG 06 Nov 2009
#define Module_MajorVersion "1.72"
#define Module_Version 172
#define Module_MajorVersion "1.73"
#define Module_Version 173
#define Module_MinorVersion ""
#define Module_Date "25 Oct 2009"
#define Module_Date "06 Nov 2009"
#define Module_ApplicationDate "25-Oct-09"
#define Module_ApplicationDate "06-Nov-09"
#define Module_ComponentName "HdrSrc"
#define Module_ComponentPath "castle/RiscOS/Sources/Programmer/HdrSrc"
#define Module_FullVersion "1.72"
#define Module_HelpVersion "1.72 (25 Oct 2009)"
#define Module_LibraryVersionInfo "1:72"
#define Module_FullVersion "1.73"
#define Module_HelpVersion "1.73 (06 Nov 2009)"
#define Module_LibraryVersionInfo "1:73"
......@@ -127,7 +127,9 @@ OldOpt SETA {OPT}
; InitialiseSWIFile
; JumpAddress $reg,$destination,$forward Set a viable (BAL to) return address
;$label LD $reg,$var,$cc Load byte or word
;$label LDHA $dest, $array, $index, $temp, $cond Load unsigned halfword from array: LDRH $dest, [$array, $index, LSL #1]
;$label LDROSB $reg, $var, $cond Load OSByte variable
;$label LDSHA $dest, $array, $index, $temp, $cond, $teq0 Load signed halfword from array, with optional TEQ $dest, #0
;$label LDW $dest, $addr, $temp1, $temp2 Load word from unknown alignment
;$label LowerCase $reg, $wrk, $nowarning Lowercase A-Z and top-bit set chars
;$label LSL $reg, $val, $cc Generate an LSL instruction
......@@ -1053,6 +1055,46 @@ $label LDR$cc.D $reg, $var
]
MEND
; ***************************************************
; *** LDHA - Load unsigned halfword from array ***
; *** This macro essentially implements: ***
; *** LDRH$cond $dest, [$array, $index, LSL #1] ***
; *** Shorter code is produced if $temp = $array ***
; *** Unsafe to use if reading ***
; *** $array+($index<<1)+2 would cause an abort ***
; *** $array must be halfword aligned! ***
; ***************************************************
MACRO
$label LDHA $dest, $array, $index, $temp, $cond
$label
ASSERT $dest <> $temp
ASSERT $dest <> $array
[ NoARMv4
; We can't rely on ARMv4 features (i.e. LDRH)
[ NoUnaligned
; We can't use unaligned loads. Use LDRB instead.
[ $temp = $array
LDR$cond.B $dest, [$array, $index, LSL #1]!
|
ADD$cond $temp, $array, $index, LSL #1
LDR$cond.B $dest, [$temp]
]
LDR$cond.B $temp, [$temp, #1]
ORR$cond $dest, $dest, $temp, LSL #8
|
; We can use an unaligned load
LDR$cond $dest, [$array, $index, LSL #1]
MOV$cond $dest, $dest, LSL #16
MOV$cond $dest, $dest, LSR #16
]
|
; We can just use LDRH
; Except LDRH with a shifted offset is only supported by Thumb2 :(
ADD$cond $temp, $array, $index, LSL #1
LDR$cond.H $dest, [$temp]
]
MEND
; ***************************************
; *** LDROSB - Load Osbyte variable ***
; ***************************************
......@@ -1062,6 +1104,54 @@ $label MOV$cond $reg, #0
LDR$cond.B $reg, [$reg, #OsbyteVars+$var-OSBYTEFirstVar]
MEND
; ***************************************************
; *** LDSHA - Load signed halfword from array ***
; *** This macro essentially implements: ***
; *** LDRSH$cond $dest, [$array, $index, LSL #1] ***
; *** Shorter code is produced if $temp = $array ***
; *** Unsafe to use if reading ***
; *** $array+($index<<1)+2 would cause an abort ***
; *** $array must be halfword aligned! ***
; *** If $teq0 = "S" then the result will be ***
; *** compared with 0 (via the S bit or via TEQ, ***
; *** i.e. the V flag won't be disturbed) ***
; ***************************************************
MACRO
$label LDSHA $dest, $array, $index, $temp, $cond, $teq0
$label
ASSERT $dest <> $temp
ASSERT $dest <> $array
ASSERT ("$teq0" = "") :LOR: ("$teq0" = "S")
[ NoARMv4
; We can't rely on ARMv4 features (i.e. LDRSH)
[ NoUnaligned
; We can't use unaligned loads. Use LDRB instead.
[ $temp = $array
LDR$cond.B $dest, [$array, $index, LSL #1]!
|
ADD$cond $temp, $array, $index, LSL #1
LDR$cond.B $dest, [$temp]
]
LDR$cond.B $temp, [$temp, #1]
MOV$cond $temp, $temp, LSL #24
ORR$cond.$teq0 $dest, $dest, $temp, ASR #16
|
; We can use an unaligned load
LDR$cond $dest, [$array, $index, LSL #1]
MOV$cond $dest, $dest, LSL #16
MOV$cond.$teq0 $dest, $dest, ASR #16
]
|
; We can just use LDRSH
; Except LDRSH with a shifted offset is only supported by Thumb2 :(
ADD$cond $temp, $array, $index, LSL #1
LDR$cond.SH $dest, [$temp]
[ "$teq0" <> ""
TEQ$cond $dest, #0
]
]
MEND
; ****************************************************
; *** LDW - Load word from unknown alignment ***
; *** $dest and $addr are allowed to match, ***
......
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