10c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Copyright (C) 2007-2008 ARM Limited
378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Licensed under the Apache License, Version 2.0 (the "License");
578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// you may not use this file except in compliance with the License.
678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// You may obtain a copy of the License at
778e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
878e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//      http://www.apache.org/licenses/LICENSE-2.0
978e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
1078e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// Unless required by applicable law or agreed to in writing, software
1178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// distributed under the License is distributed on an "AS IS" BASIS,
1278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// See the License for the specific language governing permissions and
1478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;// limitations under the License.
1578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
1678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar;//
170c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
180c1bc742181ded4930842b46e9507372f0b1b963James Dong;// File Name:  armCOMM_s.h
190c1bc742181ded4930842b46e9507372f0b1b963James Dong;// OpenMAX DL: v1.0.2
200c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Revision:   9641
210c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Date:       Thursday, February 7, 2008
220c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
230c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
240c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
250c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
260c1bc742181ded4930842b46e9507372f0b1b963James Dong;// ARM optimized OpenMAX common header file
270c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
280c1bc742181ded4930842b46e9507372f0b1b963James Dong
290c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Protect against multiple inclusion
300c1bc742181ded4930842b46e9507372f0b1b963James Dong IF :LNOT::DEF:ARMCOMM_S_H
310c1bc742181ded4930842b46e9507372f0b1b963James Dong GBLL ARMCOMM_S_H
320c1bc742181ded4930842b46e9507372f0b1b963James Dong
330c1bc742181ded4930842b46e9507372f0b1b963James Dong        REQUIRE8            ;// Requires 8-byte stack alignment
340c1bc742181ded4930842b46e9507372f0b1b963James Dong        PRESERVE8           ;// Preserves 8-byte stack alignment
350c1bc742181ded4930842b46e9507372f0b1b963James Dong
360c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL    ARM_ERRORCHECK
370c1bc742181ded4930842b46e9507372f0b1b963James DongARM_ERRORCHECK  SETL {FALSE}
380c1bc742181ded4930842b46e9507372f0b1b963James Dong
390c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Globals
400c1bc742181ded4930842b46e9507372f0b1b963James Dong
410c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _RRegList   ;// R saved register list
420c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _DRegList   ;// D saved register list
430c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _Variant    ;// Selected processor variant
440c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _CPU        ;// CPU name
450c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _Struct     ;// Structure name
460c1bc742181ded4930842b46e9507372f0b1b963James Dong
470c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL    _InFunc     ;// Inside function assembly flag
480c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL    _SwLong     ;// Long switch flag
490c1bc742181ded4930842b46e9507372f0b1b963James Dong
500c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _RBytes     ;// Number of register bytes on stack
510c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _SBytes     ;// Number of scratch bytes on stack
520c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _ABytes     ;// Stack offset of next argument
530c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _Workspace  ;// Stack offset of scratch workspace
540c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _F          ;// Function number
550c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _StOff      ;// Struct offset
560c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLA    _SwNum      ;// Switch number
570c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _32         ;// Suffix for 32 byte alignmnet
580c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLS    _16         ;// Suffix for 16 byte alignmnet
590c1bc742181ded4930842b46e9507372f0b1b963James Dong
600c1bc742181ded4930842b46e9507372f0b1b963James Dong_InFunc         SETL    {FALSE}
610c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes         SETA    0
620c1bc742181ded4930842b46e9507372f0b1b963James Dong_F              SETA    0
630c1bc742181ded4930842b46e9507372f0b1b963James Dong_SwNum          SETA    0
640c1bc742181ded4930842b46e9507372f0b1b963James Dong_32             SETS    "ALIGN32"
650c1bc742181ded4930842b46e9507372f0b1b963James Dong_16             SETS    "ALIGN16"
660c1bc742181ded4930842b46e9507372f0b1b963James Dong
670c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////////
680c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Override the tools settings of the CPU if the #define
690c1bc742181ded4930842b46e9507372f0b1b963James Dong;// USECPU is set, otherwise use the CPU defined by the
700c1bc742181ded4930842b46e9507372f0b1b963James Dong;// assembler settings.
710c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////////
720c1bc742181ded4930842b46e9507372f0b1b963James Dong
730c1bc742181ded4930842b46e9507372f0b1b963James Dong       IF :DEF: OVERRIDECPU
740c1bc742181ded4930842b46e9507372f0b1b963James Dong_CPU       SETS  OVERRIDECPU
750c1bc742181ded4930842b46e9507372f0b1b963James Dong       ELSE
760c1bc742181ded4930842b46e9507372f0b1b963James Dong_CPU       SETS    {CPU}
770c1bc742181ded4930842b46e9507372f0b1b963James Dong       ENDIF
780c1bc742181ded4930842b46e9507372f0b1b963James Dong
790c1bc742181ded4930842b46e9507372f0b1b963James Dong
800c1bc742181ded4930842b46e9507372f0b1b963James Dong
810c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////////
820c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Work out which code to build
830c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////////
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
850c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF :DEF:ARM1136JS:LOR::DEF:CortexA8:LOR::DEF:ARM_GENERIC
860c1bc742181ded4930842b46e9507372f0b1b963James Dong            INFO 1,"Please switch to using M_VARIANTS"
870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
880c1bc742181ded4930842b46e9507372f0b1b963James Dong
890c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Define and reset all officially recongnised variants
900c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
910c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANTS
920c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT ARM926EJS
930c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT ARM1136JS
940c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT ARM1136JS_U
950c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT CortexA8
960c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT ARM7TDMI
970c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
980c1bc742181ded4930842b46e9507372f0b1b963James Dong
990c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANT $var
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL $var
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL _ok$var
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong$var    SETL {FALSE}
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Variant declaration
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Define a list of code variants supported by this
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// source file. This macro then chooses the most
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// appropriate variant to build for the currently configured
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// core.
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_VARIANTS $v0,$v1,$v2,$v3,$v4,$v5,$v6,$v7
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Set to TRUE variants that are supported
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANTS
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v0
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v1
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v2
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v3
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v4
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v5
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v6
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $v7
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Look for first available variant to match a CPU
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// _M_TRY cpu, variant fall back list
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong_Variant SETS ""
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM926EJ-S,   ARM926EJS
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1176JZ-S,  ARM1136JS
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1176JZF-S, ARM1136JS
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1156T2-S,  ARM1136JS
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1156T2F-S, ARM1136JS
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1136J-S,   ARM1136JS
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM1136JF-S,  ARM1136JS
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY MPCore,       ARM1136JS
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY Cortex-A8,    CortexA8, ARM1136JS
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY Cortex-R4,    ARM1136JS
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY ARM7TDMI
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Select the correct variant
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DEF_VARIANTS
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _Variant=""
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong            INFO 1, "No match found for CPU '$_CPU'"
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong$_Variant   SETL {TRUE}
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Register a variant as available
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_VARIANT $var
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$var"=""
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF :LNOT::DEF:_ok$var
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong            INFO 1, "Unrecognized variant '$var'"
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong$var    SETL {TRUE}
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// For a given CPU, see if any of the variants supporting
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// this CPU are available. The first available variant is
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// chosen
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY $cpu, $v0,$v1,$v2,$v3,$v4,$v5,$v6,$v7
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$cpu"<>_CPU
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v0
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v1
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v2
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v3
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v4
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v5
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v6
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $v7
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Check a match was found
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _Variant=""
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong            INFO 1, "No variant match found for CPU '$_CPU'"
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_TRY1 $var
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$var"=""
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_Variant=""):LAND:$var
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong_Variant SETS "$var"
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong;////////////////////////////////////////////////////////
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Structure definition
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong;////////////////////////////////////////////////////////
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Declare a structure of given name
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRUCT $sname
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong_Struct SETS "$sname"
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong_StOff  SETA 0
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Declare a structure field
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The field is called $sname_$fname
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $size   = the size of each entry, must be power of 2
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $number = (if provided) the number of entries for an array
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_FIELD $fname, $size, $number
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_StOff:AND:($size-1))!=0
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong_StOff      SETA _StOff + ($size - (_StOff:AND:($size-1)))
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong$_Struct._$fname EQU _StOff
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$number"<>""
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong_StOff      SETA _StOff + $size*$number
2180c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong_StOff      SETA _StOff + $size
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ENDSTRUCT
2260c1bc742181ded4930842b46e9507372f0b1b963James Dongsizeof_$_Struct EQU _StOff
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong_Struct SETS ""
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong;//////////////////////////////////////////////////////////
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Switch and table macros
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong;//////////////////////////////////////////////////////////
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Start a relative switch table with register to switch on
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $v = the register to switch on
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $s = if specified must be "L" to indicate long
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//      this allows a greater range to the case code
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_SWITCH $v, $s
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT "$s"="":LOR:"$s"="L"
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong_SwLong SETL {FALSE}
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$s"="L"
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong_SwLong     SETL {TRUE}
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong_SwNum  SETA _SwNum+1
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF {CONFIG}=16
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Thumb
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF _SwLong
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong                TBH [pc, $v, LSL#1]
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong            ELSE
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong                TBB [pc, $v]
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong_Switch$_SwNum
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// ARM
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong            ADD pc, pc, $v, LSL #2
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong            NOP
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Add a case to the switch statement
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_CASE  $label
2650c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF {CONFIG}=16
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Thumb
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF _SwLong
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong                DCW ($label - _Switch$_SwNum)/2
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong            ELSE
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong                DCB ($label - _Switch$_SwNum)/2
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// ARM
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong            B   $label
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// End of switch statement
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2800c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ENDSWITCH
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ALIGN 2
2820c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
2830c1bc742181ded4930842b46e9507372f0b1b963James Dong
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong;////////////////////////////////////////////////////////
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Data area allocation
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong;////////////////////////////////////////////////////////
2880c1bc742181ded4930842b46e9507372f0b1b963James Dong
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Constant table allocator macro
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Creates a new section for each constant table
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name is symbol through which the table can be accessed.
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $align is the optional alignment of the table, log2 of
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  the byte alignment - $align=4 is 16 byte aligned
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_TABLE  $name, $align
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
2980c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$align"=""
2990c1bc742181ded4930842b46e9507372f0b1b963James Dong            AREA |.constdata|, READONLY, DATA
3000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
3010c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// AREAs inherit the alignment of the first declaration.
3020c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Therefore for each alignment size we must have an area
3030c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// of a different name.
3040c1bc742181ded4930842b46e9507372f0b1b963James Dong            AREA constdata_a$align, READONLY, DATA, ALIGN=$align
3050c1bc742181ded4930842b46e9507372f0b1b963James Dong
3060c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// We also force alignment incase we are tagging onto
3070c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// an already started area.
3080c1bc742181ded4930842b46e9507372f0b1b963James Dong            ALIGN (1<<$align)
3090c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3100c1bc742181ded4930842b46e9507372f0b1b963James Dong$name
3110c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3120c1bc742181ded4930842b46e9507372f0b1b963James Dong
3130c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////
3140c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Macros to allocate space on the stack
3150c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
3160c1bc742181ded4930842b46e9507372f0b1b963James Dong;// These all assume that the stack is 8-byte aligned
3170c1bc742181ded4930842b46e9507372f0b1b963James Dong;// at entry to the function, which means that the
3180c1bc742181ded4930842b46e9507372f0b1b963James Dong;// 32-byte alignment macro needs to work in a
3190c1bc742181ded4930842b46e9507372f0b1b963James Dong;// bit more of a special way...
3200c1bc742181ded4930842b46e9507372f0b1b963James Dong;/////////////////////////////////////////////////////
3210c1bc742181ded4930842b46e9507372f0b1b963James Dong
3220c1bc742181ded4930842b46e9507372f0b1b963James Dong
3230c1bc742181ded4930842b46e9507372f0b1b963James Dong
3240c1bc742181ded4930842b46e9507372f0b1b963James Dong
3250c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 1-byte aligned area of name
3260c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size $size bytes.
3270c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3280c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC1  $name, $size
3290c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3300c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F   EQU _SBytes
3310c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size)
3320c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3330c1bc742181ded4930842b46e9507372f0b1b963James Dong
3340c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 2-byte aligned area of name
3350c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size $size bytes.
3360c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3370c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC2  $name, $size
3380c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3390c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes:AND:1)!=0
3400c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (2 - (_SBytes:AND:1))
3410c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3420c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F   EQU _SBytes
3430c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size)
3440c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3450c1bc742181ded4930842b46e9507372f0b1b963James Dong
3460c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 4-byte aligned area of name
3470c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size $size bytes.
3480c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3490c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4  $name, $size
3500c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3510c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes:AND:3)!=0
3520c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (4 - (_SBytes:AND:3))
3530c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3540c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F   EQU _SBytes
3550c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size)
3560c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3570c1bc742181ded4930842b46e9507372f0b1b963James Dong
3580c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 8-byte aligned area of name
3590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size $size bytes.
3600c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3610c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC8  $name, $size
3620c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3630c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes:AND:7)!=0
3640c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (8 - (_SBytes:AND:7))
3650c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3660c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F   EQU _SBytes
3670c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size)
3680c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3690c1bc742181ded4930842b46e9507372f0b1b963James Dong
3700c1bc742181ded4930842b46e9507372f0b1b963James Dong
3710c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 8-byte aligned area of name
3720c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size ($size+16) bytes.
3730c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The extra 16 bytes are later used to align the pointer to 16 bytes
3740c1bc742181ded4930842b46e9507372f0b1b963James Dong
3750c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3760c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC16  $name, $size
3770c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3780c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes:AND:7)!=0
3790c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (8 - (_SBytes:AND:7))
3800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3810c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F$_16   EQU (_SBytes + 8)
3820c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size) + 8
3830c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3840c1bc742181ded4930842b46e9507372f0b1b963James Dong
3850c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate 8-byte aligned area of name
3860c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name size ($size+32) bytes.
3870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The extra 32 bytes are later used to align the pointer to 32 bytes
3880c1bc742181ded4930842b46e9507372f0b1b963James Dong
3890c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
3900c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC32  $name, $size
3910c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
3920c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes:AND:7)!=0
3930c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (8 - (_SBytes:AND:7))
3940c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
3950c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F$_32   EQU (_SBytes + 24)
3960c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes SETA _SBytes + ($size) + 24
3970c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
3980c1bc742181ded4930842b46e9507372f0b1b963James Dong
3990c1bc742181ded4930842b46e9507372f0b1b963James Dong
4000c1bc742181ded4930842b46e9507372f0b1b963James Dong
4010c1bc742181ded4930842b46e9507372f0b1b963James Dong
4020c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Argument Declaration Macro
4030c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
4040c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate an argument name $name
4050c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// size $size bytes
4060c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
4070c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG     $name, $size
4080c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT _InFunc
4090c1bc742181ded4930842b46e9507372f0b1b963James Dong$name$_F    EQU _ABytes
4100c1bc742181ded4930842b46e9507372f0b1b963James Dong_ABytes SETA _ABytes + ($size)
4110c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
4120c1bc742181ded4930842b46e9507372f0b1b963James Dong
4130c1bc742181ded4930842b46e9507372f0b1b963James Dong;///////////////////////////////////////////////
4140c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Macros to access stacked variables
4150c1bc742181ded4930842b46e9507372f0b1b963James Dong;///////////////////////////////////////////////
4160c1bc742181ded4930842b46e9507372f0b1b963James Dong
4170c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Macro to perform a data processing operation
4180c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// with a constant second operand
4190c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
4200c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_OPC $op,$rd,$rn,$const
4210c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLA    _sh
4220c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLA    _cst
4230c1bc742181ded4930842b46e9507372f0b1b963James Dong_sh     SETA    0
4240c1bc742181ded4930842b46e9507372f0b1b963James Dong_cst    SETA    $const
4250c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _cst=0
4260c1bc742181ded4930842b46e9507372f0b1b963James Dong        $op $rd, $rn, #_cst
4270c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
4280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
4290c1bc742181ded4930842b46e9507372f0b1b963James Dong        WHILE (_cst:AND:3)=0
4300c1bc742181ded4930842b46e9507372f0b1b963James Dong_cst        SETA _cst>>2
4310c1bc742181ded4930842b46e9507372f0b1b963James Dong_sh         SETA _sh+2
4320c1bc742181ded4930842b46e9507372f0b1b963James Dong        WEND
4330c1bc742181ded4930842b46e9507372f0b1b963James Dong        $op $rd, $rn, #(_cst:AND:0x000000FF)<<_sh
4340c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _cst>=256
4350c1bc742181ded4930842b46e9507372f0b1b963James Dong            $op $rd, $rd, #(_cst:AND:0xFFFFFF00)<<_sh
4360c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
4370c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
4380c1bc742181ded4930842b46e9507372f0b1b963James Dong
4390c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Macro to perform a data access operation
4400c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Such as LDR or STR
4410c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The addressing mode is modified such that
4420c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// 1. If no address is given then the name is taken
4430c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//    as a stack offset
4440c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// 2. If the addressing mode is not available for the
4450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//    state being assembled for (eg Thumb) then a suitable
4460c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//    addressing mode is substituted.
4470c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
4480c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// On Entry:
4490c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $i = Instruction to perform (eg "LDRB")
4500c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $a = Required byte alignment
4510c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $r = Register(s) to transfer (eg "r1")
4520c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $a0,$a1,$a2. Addressing mode and condition. One of:
4530c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     label {,cc}
4540c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     [base]                    {,,,cc}
4550c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     [base, offset]{!}         {,,cc}
4560c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     [base, offset, shift]{!}  {,cc}
4570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     [base], offset            {,,cc}
4580c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//     [base], offset, shift     {,cc}
4590c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
4600c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA $i,$a,$r,$a0,$a1,$a2,$a3
4610c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$a0":LEFT:1="["
4620c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF "$a1"=""
4630c1bc742181ded4930842b46e9507372f0b1b963James Dong                $i$a3   $r, $a0
4640c1bc742181ded4930842b46e9507372f0b1b963James Dong            ELSE
4650c1bc742181ded4930842b46e9507372f0b1b963James Dong                IF "$a0":RIGHT:1="]"
4660c1bc742181ded4930842b46e9507372f0b1b963James Dong                    IF "$a2"=""
4670c1bc742181ded4930842b46e9507372f0b1b963James Dong                        _M_POSTIND $i$a3, "$r", $a0, $a1
4680c1bc742181ded4930842b46e9507372f0b1b963James Dong                    ELSE
4690c1bc742181ded4930842b46e9507372f0b1b963James Dong                        _M_POSTIND $i$a3, "$r", $a0, "$a1,$a2"
4700c1bc742181ded4930842b46e9507372f0b1b963James Dong                    ENDIF
4710c1bc742181ded4930842b46e9507372f0b1b963James Dong                ELSE
4720c1bc742181ded4930842b46e9507372f0b1b963James Dong                    IF "$a2"=""
4730c1bc742181ded4930842b46e9507372f0b1b963James Dong                        _M_PREIND  $i$a3, "$r", $a0, $a1
4740c1bc742181ded4930842b46e9507372f0b1b963James Dong                    ELSE
4750c1bc742181ded4930842b46e9507372f0b1b963James Dong                        _M_PREIND  $i$a3, "$r", $a0, "$a1,$a2"
4760c1bc742181ded4930842b46e9507372f0b1b963James Dong                    ENDIF
4770c1bc742181ded4930842b46e9507372f0b1b963James Dong                ENDIF
4780c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
4790c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
4800c1bc742181ded4930842b46e9507372f0b1b963James Dong            LCLA    _Offset
4810c1bc742181ded4930842b46e9507372f0b1b963James Dong_Offset     SETA    _Workspace + $a0$_F
4820c1bc742181ded4930842b46e9507372f0b1b963James Dong            ASSERT  (_Offset:AND:($a-1))=0
4830c1bc742181ded4930842b46e9507372f0b1b963James Dong            $i$a1   $r, [sp, #_Offset]
4840c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
4850c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
4860c1bc742181ded4930842b46e9507372f0b1b963James Dong
4870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Handle post indexed load/stores
4880c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// op  reg, [base], offset
4890c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
4900c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_POSTIND $i,$r,$a0,$a1
4910c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLS _base
4920c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLS _offset
4930c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF {CONFIG}=16 ;// Thumb
4940c1bc742181ded4930842b46e9507372f0b1b963James Dong_base       SETS ("$a0":LEFT:(:LEN:"$a0"-1)):RIGHT:(:LEN:"$a0"-2)   ;// remove []
4950c1bc742181ded4930842b46e9507372f0b1b963James Dong_offset     SETS "$a1"
4960c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF _offset:LEFT:1="+"
4970c1bc742181ded4930842b46e9507372f0b1b963James Dong_offset         SETS _offset:RIGHT:(:LEN:_offset-1)
4980c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
4990c1bc742181ded4930842b46e9507372f0b1b963James Dong            $i  $r, $a0
5000c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF _offset:LEFT:1="-"
5010c1bc742181ded4930842b46e9507372f0b1b963James Dong_offset         SETS _offset:RIGHT:(:LEN:_offset-1)
5020c1bc742181ded4930842b46e9507372f0b1b963James Dong                SUB $_base, $_base, $_offset
5030c1bc742181ded4930842b46e9507372f0b1b963James Dong            ELSE
5040c1bc742181ded4930842b46e9507372f0b1b963James Dong                ADD $_base, $_base, $_offset
5050c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
5060c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE ;// ARM
5070c1bc742181ded4930842b46e9507372f0b1b963James Dong            $i  $r, $a0, $a1
5080c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
5090c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5100c1bc742181ded4930842b46e9507372f0b1b963James Dong
5110c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Handle pre indexed load/store
5120c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// op  reg, [base, offset]{!}
5130c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5140c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_PREIND $i,$r,$a0,$a1
5150c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLS _base
5160c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLS _offset
5170c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ({CONFIG}=16):LAND:(("$a1":RIGHT:2)="]!")
5180c1bc742181ded4930842b46e9507372f0b1b963James Dong_base       SETS "$a0":RIGHT:(:LEN:("$a0")-1)
5190c1bc742181ded4930842b46e9507372f0b1b963James Dong_offset     SETS "$a1":LEFT:(:LEN:("$a1")-2)
5200c1bc742181ded4930842b46e9507372f0b1b963James Dong            $i $r, [$_base, $_offset]
5210c1bc742181ded4930842b46e9507372f0b1b963James Dong            ADD $_base, $_base, $_offset
5220c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
5230c1bc742181ded4930842b46e9507372f0b1b963James Dong            $i  $r, $a0, $a1
5240c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
5250c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5260c1bc742181ded4930842b46e9507372f0b1b963James Dong
5270c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load unsigned byte from stack
5280c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5290c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRB  $r,$a0,$a1,$a2,$a3
5300c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDRB",1,$r,$a0,$a1,$a2,$a3
5310c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5320c1bc742181ded4930842b46e9507372f0b1b963James Dong
5330c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load signed byte from stack
5340c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5350c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRSB $r,$a0,$a1,$a2,$a3
5360c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDRSB",1,$r,$a0,$a1,$a2,$a3
5370c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5380c1bc742181ded4930842b46e9507372f0b1b963James Dong
5390c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store byte to stack
5400c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5410c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRB  $r,$a0,$a1,$a2,$a3
5420c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "STRB",1,$r,$a0,$a1,$a2,$a3
5430c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5440c1bc742181ded4930842b46e9507372f0b1b963James Dong
5450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load unsigned half word from stack
5460c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5470c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRH  $r,$a0,$a1,$a2,$a3
5480c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDRH",2,$r,$a0,$a1,$a2,$a3
5490c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5500c1bc742181ded4930842b46e9507372f0b1b963James Dong
5510c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load signed half word from stack
5520c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5530c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRSH $r,$a0,$a1,$a2,$a3
5540c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDRSH",2,$r,$a0,$a1,$a2,$a3
5550c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5560c1bc742181ded4930842b46e9507372f0b1b963James Dong
5570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store half word to stack
5580c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5590c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRH  $r,$a0,$a1,$a2,$a3
5600c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "STRH",2,$r,$a0,$a1,$a2,$a3
5610c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5620c1bc742181ded4930842b46e9507372f0b1b963James Dong
5630c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load word from stack
5640c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5650c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   $r,$a0,$a1,$a2,$a3
5660c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDR",4,$r,$a0,$a1,$a2,$a3
5670c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5680c1bc742181ded4930842b46e9507372f0b1b963James Dong
5690c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store word to stack
5700c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5710c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   $r,$a0,$a1,$a2,$a3
5720c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "STR",4,$r,$a0,$a1,$a2,$a3
5730c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5740c1bc742181ded4930842b46e9507372f0b1b963James Dong
5750c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load double word from stack
5760c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5770c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  $r0,$r1,$a0,$a1,$a2,$a3
5780c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "LDRD",8,"$r0,$r1",$a0,$a1,$a2,$a3
5790c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5800c1bc742181ded4930842b46e9507372f0b1b963James Dong
5810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store double word to stack
5820c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5830c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRD  $r0,$r1,$a0,$a1,$a2,$a3
5840c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_DATA "STRD",8,"$r0,$r1",$a0,$a1,$a2,$a3
5850c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5860c1bc742181ded4930842b46e9507372f0b1b963James Dong
5870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Get absolute address of stack allocated location
5880c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5890c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ADR   $a, $b, $cc
5900c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_OPC  ADD$cc, $a, sp, (_Workspace + $b$_F)
5910c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
5920c1bc742181ded4930842b46e9507372f0b1b963James Dong
5930c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Get absolute address of stack allocated location and align the address to 16 bytes
5940c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
5950c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ADR16 $a, $b, $cc
5960c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_OPC  ADD$cc, $a, sp, (_Workspace + $b$_F$_16)
5970c1bc742181ded4930842b46e9507372f0b1b963James Dong
5980c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Now align $a to 16 bytes
5990c1bc742181ded4930842b46e9507372f0b1b963James Dong            BIC$cc  $a,$a,#0x0F
6000c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
6010c1bc742181ded4930842b46e9507372f0b1b963James Dong
6020c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Get absolute address of stack allocated location and align the address to 32 bytes
6030c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
6040c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ADR32 $a, $b, $cc
6050c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_OPC  ADD$cc, $a, sp, (_Workspace + $b$_F$_32)
6060c1bc742181ded4930842b46e9507372f0b1b963James Dong
6070c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Now align $a to 32 bytes
6080c1bc742181ded4930842b46e9507372f0b1b963James Dong            BIC$cc  $a,$a,#0x1F
6090c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
6100c1bc742181ded4930842b46e9507372f0b1b963James Dong
6110c1bc742181ded4930842b46e9507372f0b1b963James Dong;//////////////////////////////////////////////////////////
6120c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Function header and footer macros
6130c1bc742181ded4930842b46e9507372f0b1b963James Dong;//////////////////////////////////////////////////////////
6140c1bc742181ded4930842b46e9507372f0b1b963James Dong
6150c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Function Header Macro
6160c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Generates the function prologue
6170c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Note that functions should all be "stack-moves-once"
6180c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The FNSTART and FNEND macros should be the only places
6190c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// where the stack moves.
6200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
6210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $name  = function name
6220c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $rreg  = ""   don't stack any registers
6230c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//          "lr" stack "lr" only
6240c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//          "rN" stack registers "r4-rN,lr"
6250c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $dreg  = ""   don't stack any D registers
6260c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//          "dN" stack registers "d8-dN"
6270c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
6280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Note: ARM Archicture procedure call standard AAPCS
6290c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// states that r4-r11, sp, d8-d15 must be preserved by
6300c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// a compliant function.
6310c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
6320c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_START $name, $rreg, $dreg
6330c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT :LNOT:_InFunc
6340c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT "$name"!=""
6350c1bc742181ded4930842b46e9507372f0b1b963James Dong_InFunc SETL {TRUE}
6360c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes SETA 0
6370c1bc742181ded4930842b46e9507372f0b1b963James Dong_Workspace SETA 0
6380c1bc742181ded4930842b46e9507372f0b1b963James Dong
6390c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Create an area for the function
6400c1bc742181ded4930842b46e9507372f0b1b963James Dong        AREA    |.text|, CODE
6410c1bc742181ded4930842b46e9507372f0b1b963James Dong        EXPORT  $name
6420c1bc742181ded4930842b46e9507372f0b1b963James Dong$name   FUNCTION
6430c1bc742181ded4930842b46e9507372f0b1b963James Dong
6440c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Save R registers
6450c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_GETRREGLIST $rreg
6460c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _RRegList<>""
6470c1bc742181ded4930842b46e9507372f0b1b963James Dong            STMFD   sp!, {$_RRegList, lr}
6480c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6490c1bc742181ded4930842b46e9507372f0b1b963James Dong
6500c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Save D registers
6510c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_GETDREGLIST  $dreg
6520c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _DRegList<>""
6530c1bc742181ded4930842b46e9507372f0b1b963James Dong            VSTMFD  sp!, {$_DRegList}
6540c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6550c1bc742181ded4930842b46e9507372f0b1b963James Dong
6560c1bc742181ded4930842b46e9507372f0b1b963James Dong
6570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Ensure size claimed on stack is 8-byte aligned
6580c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ((_SBytes:AND:7)!=0)
6590c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes     SETA _SBytes + (8 - (_SBytes:AND:7))
6600c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6610c1bc742181ded4930842b46e9507372f0b1b963James Dong
6620c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF (_SBytes!=0)
6630c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_OPC SUB, sp, sp, _SBytes
6640c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6650c1bc742181ded4930842b46e9507372f0b1b963James Dong
6660c1bc742181ded4930842b46e9507372f0b1b963James Dong
6670c1bc742181ded4930842b46e9507372f0b1b963James Dong_ABytes SETA _SBytes + _RBytes - _Workspace
6680c1bc742181ded4930842b46e9507372f0b1b963James Dong
6690c1bc742181ded4930842b46e9507372f0b1b963James Dong
6700c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Print function name if debug enabled
6710c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_PRINTF "$name\n",
6720c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
6730c1bc742181ded4930842b46e9507372f0b1b963James Dong
6740c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Work out a list of R saved registers
6750c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
6760c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_GETRREGLIST $rreg
6770c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"=""
6780c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS ""
6790c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
6800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6810c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"="lr":LOR:"$rreg"="r4"
6820c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS "r4"
6830c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+8
6840c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
6850c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6860c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"="r5":LOR:"$rreg"="r6"
6870c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS "r4-r6"
6880c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+16
6890c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
6900c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6910c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"="r7":LOR:"$rreg"="r8"
6920c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS "r4-r8"
6930c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+24
6940c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
6950c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
6960c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"="r9":LOR:"$rreg"="r10"
6970c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS "r4-r10"
6980c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+32
6990c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7010c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$rreg"="r11":LOR:"$rreg"="r12"
7020c1bc742181ded4930842b46e9507372f0b1b963James Dong_RRegList   SETS "r4-r12"
7030c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+40
7040c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7050c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7060c1bc742181ded4930842b46e9507372f0b1b963James Dong        INFO 1, "Unrecognized saved r register limit '$rreg'"
7070c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
7080c1bc742181ded4930842b46e9507372f0b1b963James Dong
7090c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Work out a list of D saved registers
7100c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
7110c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_GETDREGLIST $dreg
7120c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"=""
7130c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS ""
7140c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7150c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7160c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d8"
7170c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8"
7180c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+8
7190c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7210c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d9"
7220c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d9"
7230c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+16
7240c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7250c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7260c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d10"
7270c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d10"
7280c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+24
7290c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7300c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7310c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d11"
7320c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d11"
7330c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+32
7340c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7350c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7360c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d12"
7370c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d12"
7380c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+40
7390c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7400c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7410c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d13"
7420c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d13"
7430c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+48
7440c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7460c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d14"
7470c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d14"
7480c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+56
7490c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7500c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7510c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$dreg"="d15"
7520c1bc742181ded4930842b46e9507372f0b1b963James Dong_DRegList   SETS "d8-d15"
7530c1bc742181ded4930842b46e9507372f0b1b963James Dong_RBytes     SETA _RBytes+64
7540c1bc742181ded4930842b46e9507372f0b1b963James Dong            MEXIT
7550c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7560c1bc742181ded4930842b46e9507372f0b1b963James Dong        INFO 1, "Unrecognized saved d register limit '$dreg'"
7570c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
7580c1bc742181ded4930842b46e9507372f0b1b963James Dong
7590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Produce function return instructions
7600c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
7610c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_RET $cc
7620c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _DRegList<>""
7630c1bc742181ded4930842b46e9507372f0b1b963James Dong            VPOP$cc {$_DRegList}
7640c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7650c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _RRegList=""
7660c1bc742181ded4930842b46e9507372f0b1b963James Dong            BX$cc lr
7670c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
7680c1bc742181ded4930842b46e9507372f0b1b963James Dong            LDM$cc.FD sp!, {$_RRegList, pc}
7690c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7700c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
7710c1bc742181ded4930842b46e9507372f0b1b963James Dong
7720c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Early Function Exit Macro
7730c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// $cc = condition to exit with
7740c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// (Example: M_EXIT EQ)
7750c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
7760c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_EXIT  $cc
7770c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT  _InFunc
7780c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF  _SBytes!=0
7790c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Restore stack frame and exit
7800c1bc742181ded4930842b46e9507372f0b1b963James Dong            B$cc  _End$_F
7810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
7820c1bc742181ded4930842b46e9507372f0b1b963James Dong            ;// Can return directly
7830c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_RET $cc
7840c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7850c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
7860c1bc742181ded4930842b46e9507372f0b1b963James Dong
7870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Function Footer Macro
7880c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Generates the function epilogue
7890c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
7900c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_END
7910c1bc742181ded4930842b46e9507372f0b1b963James Dong        ASSERT _InFunc
7920c1bc742181ded4930842b46e9507372f0b1b963James Dong_InFunc SETL {FALSE}
7930c1bc742181ded4930842b46e9507372f0b1b963James Dong_End$_F
7940c1bc742181ded4930842b46e9507372f0b1b963James Dong
7950c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Restore the stack pointer to its original value on function entry
7960c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF _SBytes!=0
7970c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_OPC ADD, sp, sp, _SBytes
7980c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
7990c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_RET
8000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDFUNC
8010c1bc742181ded4930842b46e9507372f0b1b963James Dong
8020c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Reset the global stack tracking variables back to their
8030c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// initial values, and increment the function count
8040c1bc742181ded4930842b46e9507372f0b1b963James Dong_SBytes        SETA 0
8050c1bc742181ded4930842b46e9507372f0b1b963James Dong_F             SETA _F+1
8060c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
8070c1bc742181ded4930842b46e9507372f0b1b963James Dong
8080c1bc742181ded4930842b46e9507372f0b1b963James Dong
8090c1bc742181ded4930842b46e9507372f0b1b963James Dong;//==========================================================================
8100c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Debug Macros
8110c1bc742181ded4930842b46e9507372f0b1b963James Dong;//==========================================================================
8120c1bc742181ded4930842b46e9507372f0b1b963James Dong
8130c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL    DEBUG_ON
8140c1bc742181ded4930842b46e9507372f0b1b963James DongDEBUG_ON SETL   {FALSE}
8150c1bc742181ded4930842b46e9507372f0b1b963James Dong        GBLL    DEBUG_STALLS_ON
8160c1bc742181ded4930842b46e9507372f0b1b963James DongDEBUG_STALLS_ON SETL {FALSE}
8170c1bc742181ded4930842b46e9507372f0b1b963James Dong
8180c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//==========================================================================
8190c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Debug call to printf
8200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  M_PRINTF $format, $val0, $val1, $val2
8210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
8220c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Examples:
8230c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  M_PRINTF "x=%08x\n", r0
8240c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
8250c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// This macro preserves the value of all registers including the
8260c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// flags.
8270c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//==========================================================================
8280c1bc742181ded4930842b46e9507372f0b1b963James Dong
8290c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
8300c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_PRINTF  $format, $val0, $val1, $val2
8310c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF DEBUG_ON
8320c1bc742181ded4930842b46e9507372f0b1b963James Dong
8330c1bc742181ded4930842b46e9507372f0b1b963James Dong        IMPORT  printf
8340c1bc742181ded4930842b46e9507372f0b1b963James Dong        LCLA    nArgs
8350c1bc742181ded4930842b46e9507372f0b1b963James DongnArgs	SETA    0
8360c1bc742181ded4930842b46e9507372f0b1b963James Dong
8370c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// save registers so we don't corrupt them
8380c1bc742181ded4930842b46e9507372f0b1b963James Dong        STMFD   sp!, {r0-r12, lr}
8390c1bc742181ded4930842b46e9507372f0b1b963James Dong
8400c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Drop stack to give us some workspace
8410c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     sp, sp, #16
8420c1bc742181ded4930842b46e9507372f0b1b963James Dong
8430c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Save registers we need to print to the stack
8440c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$val2" <> ""
8450c1bc742181ded4930842b46e9507372f0b1b963James Dong            ASSERT "$val1" <> ""
8460c1bc742181ded4930842b46e9507372f0b1b963James Dong            STR    $val2, [sp, #8]
8470c1bc742181ded4930842b46e9507372f0b1b963James DongnArgs       SETA   nArgs+1
8480c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8490c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$val1" <> ""
8500c1bc742181ded4930842b46e9507372f0b1b963James Dong            ASSERT "$val0" <> ""
8510c1bc742181ded4930842b46e9507372f0b1b963James Dong            STR    $val1, [sp, #4]
8520c1bc742181ded4930842b46e9507372f0b1b963James DongnArgs	    SETA   nArgs+1
8530c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8540c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$val0"<>""
8550c1bc742181ded4930842b46e9507372f0b1b963James Dong            STR    $val0, [sp]
8560c1bc742181ded4930842b46e9507372f0b1b963James DongnArgs	    SETA   nArgs+1
8570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8580c1bc742181ded4930842b46e9507372f0b1b963James Dong
8590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Now we are safe to corrupt registers
8600c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADR     r0, %FT00
8610c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF nArgs=1
8620c1bc742181ded4930842b46e9507372f0b1b963James Dong          LDR   r1, [sp]
8630c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8640c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF nArgs=2
8650c1bc742181ded4930842b46e9507372f0b1b963James Dong          LDMIA sp, {r1,r2}
8660c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8670c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF nArgs=3
8680c1bc742181ded4930842b46e9507372f0b1b963James Dong          LDMIA sp, {r1,r2,r3}
8690c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
8700c1bc742181ded4930842b46e9507372f0b1b963James Dong
8710c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// print the values
8720c1bc742181ded4930842b46e9507372f0b1b963James Dong        MRS     r4, cpsr        ;// preserve flags
8730c1bc742181ded4930842b46e9507372f0b1b963James Dong        BL      printf
8740c1bc742181ded4930842b46e9507372f0b1b963James Dong        MSR     cpsr_f, r4      ;// restore flags
8750c1bc742181ded4930842b46e9507372f0b1b963James Dong        B       %FT01
8760c1bc742181ded4930842b46e9507372f0b1b963James Dong00      ;// string to print
8770c1bc742181ded4930842b46e9507372f0b1b963James Dong        DCB     "$format", 0
8780c1bc742181ded4930842b46e9507372f0b1b963James Dong        ALIGN
8790c1bc742181ded4930842b46e9507372f0b1b963James Dong01      ;// Finished
8800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     sp, sp, #16
8810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Restore registers
8820c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDMFD	sp!, {r0-r12,lr}
8830c1bc742181ded4930842b46e9507372f0b1b963James Dong
8840c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF   ;// DEBUG_ON
8850c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
8860c1bc742181ded4930842b46e9507372f0b1b963James Dong
8870c1bc742181ded4930842b46e9507372f0b1b963James Dong
8880c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Stall Simulation Macro
8890c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Inserts a given number of NOPs for the currently
8900c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  defined platform
8910c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
8920c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STALL $plat1stall, $plat2stall, $plat3stall, $plat4stall, $plat5stall, $plat6stall
8930c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF DEBUG_STALLS_ON
8940c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat1stall
8950c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat2stall
8960c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat3stall
8970c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat4stall
8980c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat5stall
8990c1bc742181ded4930842b46e9507372f0b1b963James Dong            _M_STALL_SUB $plat6stall
9000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
9010c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9020c1bc742181ded4930842b46e9507372f0b1b963James Dong
9030c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9040c1bc742181ded4930842b46e9507372f0b1b963James Dong        _M_STALL_SUB $platstall
9050c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF "$platstall"!=""
9060c1bc742181ded4930842b46e9507372f0b1b963James Dong            LCLA _pllen
9070c1bc742181ded4930842b46e9507372f0b1b963James Dong            LCLS _pl
9080c1bc742181ded4930842b46e9507372f0b1b963James Dong            LCLL _pllog
9090c1bc742181ded4930842b46e9507372f0b1b963James Dong_pllen      SETA :LEN:"$platstall"
9100c1bc742181ded4930842b46e9507372f0b1b963James Dong_pl         SETS "$platstall":LEFT:(_pllen - 2)
9110c1bc742181ded4930842b46e9507372f0b1b963James Dong            IF :DEF:$_pl
9120c1bc742181ded4930842b46e9507372f0b1b963James Dong                IF $_pl
9130c1bc742181ded4930842b46e9507372f0b1b963James Dong                    LCLS _st
9140c1bc742181ded4930842b46e9507372f0b1b963James Dong                    LCLA _stnum
9150c1bc742181ded4930842b46e9507372f0b1b963James Dong_st                 SETS "$platstall":RIGHT:1
9160c1bc742181ded4930842b46e9507372f0b1b963James Dong_stnum              SETA $_st
9170c1bc742181ded4930842b46e9507372f0b1b963James Dong                    WHILE _stnum>0
9180c1bc742181ded4930842b46e9507372f0b1b963James Dong			MOV sp, sp
9190c1bc742181ded4930842b46e9507372f0b1b963James Dong_stnum                  SETA _stnum - 1
9200c1bc742181ded4930842b46e9507372f0b1b963James Dong                    WEND
9210c1bc742181ded4930842b46e9507372f0b1b963James Dong                ENDIF
9220c1bc742181ded4930842b46e9507372f0b1b963James Dong            ENDIF
9230c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
9240c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9250c1bc742181ded4930842b46e9507372f0b1b963James Dong
9260c1bc742181ded4930842b46e9507372f0b1b963James Dong
9270c1bc742181ded4930842b46e9507372f0b1b963James Dong
9280c1bc742181ded4930842b46e9507372f0b1b963James Dong;//==========================================================================
9290c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Endian Invarience Macros
9300c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
9310c1bc742181ded4930842b46e9507372f0b1b963James Dong;// The idea behind these macros is that if an array is
9320c1bc742181ded4930842b46e9507372f0b1b963James Dong;// loaded as words then the SMUL00 macro will multiply
9330c1bc742181ded4930842b46e9507372f0b1b963James Dong;// array elements 0 regardless of the endianess of the
9340c1bc742181ded4930842b46e9507372f0b1b963James Dong;// system. For little endian SMUL00=SMULBB, for big
9350c1bc742181ded4930842b46e9507372f0b1b963James Dong;// endian SMUL00=SMULTT and similarly for other packed operations.
9360c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
9370c1bc742181ded4930842b46e9507372f0b1b963James Dong;//==========================================================================
9380c1bc742181ded4930842b46e9507372f0b1b963James Dong
9390c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9400c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4   $comli, $combi, $a, $b, $c, $d, $cc
9410c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF {ENDIAN}="big"
9420c1bc742181ded4930842b46e9507372f0b1b963James Dong        $combi.$cc $a, $b, $c, $d
9430c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
9440c1bc742181ded4930842b46e9507372f0b1b963James Dong        $comli.$cc $a, $b, $c, $d
9450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
9460c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9470c1bc742181ded4930842b46e9507372f0b1b963James Dong
9480c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9490c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3   $comli, $combi, $a, $b, $c, $cc
9500c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF {ENDIAN}="big"
9510c1bc742181ded4930842b46e9507372f0b1b963James Dong        $combi.$cc $a, $b, $c
9520c1bc742181ded4930842b46e9507372f0b1b963James Dong        ELSE
9530c1bc742181ded4930842b46e9507372f0b1b963James Dong        $comli.$cc $a, $b, $c
9540c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
9550c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9560c1bc742181ded4930842b46e9507372f0b1b963James Dong
9570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// SMLAxy macros
9580c1bc742181ded4930842b46e9507372f0b1b963James Dong
9590c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9600c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA00  $a, $b, $c, $d, $cc
9610c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABB, SMLATT, $a, $b, $c, $d, $cc
9620c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9630c1bc742181ded4930842b46e9507372f0b1b963James Dong
9640c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9650c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA01  $a, $b, $c, $d, $cc
9660c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABT, SMLATB, $a, $b, $c, $d, $cc
9670c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9680c1bc742181ded4930842b46e9507372f0b1b963James Dong
9690c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9700c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA0B  $a, $b, $c, $d, $cc
9710c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABB, SMLATB, $a, $b, $c, $d, $cc
9720c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9730c1bc742181ded4930842b46e9507372f0b1b963James Dong
9740c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9750c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA0T  $a, $b, $c, $d, $cc
9760c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABT, SMLATT, $a, $b, $c, $d, $cc
9770c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9780c1bc742181ded4930842b46e9507372f0b1b963James Dong
9790c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9800c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA10  $a, $b, $c, $d, $cc
9810c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATB, SMLABT, $a, $b, $c, $d, $cc
9820c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9830c1bc742181ded4930842b46e9507372f0b1b963James Dong
9840c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9850c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA11  $a, $b, $c, $d, $cc
9860c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATT, SMLABB, $a, $b, $c, $d, $cc
9870c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9880c1bc742181ded4930842b46e9507372f0b1b963James Dong
9890c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9900c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA1B  $a, $b, $c, $d, $cc
9910c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATB, SMLABB, $a, $b, $c, $d, $cc
9920c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9930c1bc742181ded4930842b46e9507372f0b1b963James Dong
9940c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
9950c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLA1T  $a, $b, $c, $d, $cc
9960c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATT, SMLABT, $a, $b, $c, $d, $cc
9970c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
9980c1bc742181ded4930842b46e9507372f0b1b963James Dong
9990c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10000c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAB0  $a, $b, $c, $d, $cc
10010c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABB, SMLABT, $a, $b, $c, $d, $cc
10020c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10030c1bc742181ded4930842b46e9507372f0b1b963James Dong
10040c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10050c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAB1  $a, $b, $c, $d, $cc
10060c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLABT, SMLABB, $a, $b, $c, $d, $cc
10070c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10080c1bc742181ded4930842b46e9507372f0b1b963James Dong
10090c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10100c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAT0  $a, $b, $c, $d, $cc
10110c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATB, SMLATT, $a, $b, $c, $d, $cc
10120c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10130c1bc742181ded4930842b46e9507372f0b1b963James Dong
10140c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10150c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAT1  $a, $b, $c, $d, $cc
10160c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLATT, SMLATB, $a, $b, $c, $d, $cc
10170c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10180c1bc742181ded4930842b46e9507372f0b1b963James Dong
10190c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// SMULxy macros
10200c1bc742181ded4930842b46e9507372f0b1b963James Dong
10210c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10220c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL00  $a, $b, $c, $cc
10230c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBB, SMULTT, $a, $b, $c, $cc
10240c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10250c1bc742181ded4930842b46e9507372f0b1b963James Dong
10260c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10270c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL01  $a, $b, $c, $cc
10280c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBT, SMULTB, $a, $b, $c, $cc
10290c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10300c1bc742181ded4930842b46e9507372f0b1b963James Dong
10310c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10320c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL0B  $a, $b, $c, $cc
10330c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBB, SMULTB, $a, $b, $c, $cc
10340c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10350c1bc742181ded4930842b46e9507372f0b1b963James Dong
10360c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10370c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL0T  $a, $b, $c, $cc
10380c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBT, SMULTT, $a, $b, $c, $cc
10390c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10400c1bc742181ded4930842b46e9507372f0b1b963James Dong
10410c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10420c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL10  $a, $b, $c, $cc
10430c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTB, SMULBT, $a, $b, $c, $cc
10440c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10450c1bc742181ded4930842b46e9507372f0b1b963James Dong
10460c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10470c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL11  $a, $b, $c, $cc
10480c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTT, SMULBB, $a, $b, $c, $cc
10490c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10500c1bc742181ded4930842b46e9507372f0b1b963James Dong
10510c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10520c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL1B  $a, $b, $c, $cc
10530c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTB, SMULBB, $a, $b, $c, $cc
10540c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10550c1bc742181ded4930842b46e9507372f0b1b963James Dong
10560c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10570c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMUL1T  $a, $b, $c, $cc
10580c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTT, SMULBT, $a, $b, $c, $cc
10590c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10600c1bc742181ded4930842b46e9507372f0b1b963James Dong
10610c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10620c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULB0  $a, $b, $c, $cc
10630c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBB, SMULBT, $a, $b, $c, $cc
10640c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10650c1bc742181ded4930842b46e9507372f0b1b963James Dong
10660c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10670c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULB1  $a, $b, $c, $cc
10680c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULBT, SMULBB, $a, $b, $c, $cc
10690c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10700c1bc742181ded4930842b46e9507372f0b1b963James Dong
10710c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10720c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULT0  $a, $b, $c, $cc
10730c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTB, SMULTT, $a, $b, $c, $cc
10740c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10750c1bc742181ded4930842b46e9507372f0b1b963James Dong
10760c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10770c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULT1  $a, $b, $c, $cc
10780c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULTT, SMULTB, $a, $b, $c, $cc
10790c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10800c1bc742181ded4930842b46e9507372f0b1b963James Dong
10810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// SMLAWx, SMULWx macros
10820c1bc742181ded4930842b46e9507372f0b1b963James Dong
10830c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10840c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAW0  $a, $b, $c, $d, $cc
10850c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLAWB, SMLAWT, $a, $b, $c, $d, $cc
10860c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10870c1bc742181ded4930842b46e9507372f0b1b963James Dong
10880c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10890c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAW1  $a, $b, $c, $d, $cc
10900c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLAWT, SMLAWB, $a, $b, $c, $d, $cc
10910c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10920c1bc742181ded4930842b46e9507372f0b1b963James Dong
10930c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10940c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULW0  $a, $b, $c, $cc
10950c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULWB, SMULWT, $a, $b, $c, $cc
10960c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
10970c1bc742181ded4930842b46e9507372f0b1b963James Dong
10980c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
10990c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMULW1  $a, $b, $c, $cc
11000c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI3 SMULWT, SMULWB, $a, $b, $c, $cc
11010c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11020c1bc742181ded4930842b46e9507372f0b1b963James Dong
11030c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// SMLALxy macros
11040c1bc742181ded4930842b46e9507372f0b1b963James Dong
11050c1bc742181ded4930842b46e9507372f0b1b963James Dong
11060c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11070c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL00  $a, $b, $c, $d, $cc
11080c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBB, SMLALTT, $a, $b, $c, $d, $cc
11090c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11100c1bc742181ded4930842b46e9507372f0b1b963James Dong
11110c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11120c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL01  $a, $b, $c, $d, $cc
11130c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBT, SMLALTB, $a, $b, $c, $d, $cc
11140c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11150c1bc742181ded4930842b46e9507372f0b1b963James Dong
11160c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11170c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL0B  $a, $b, $c, $d, $cc
11180c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBB, SMLALTB, $a, $b, $c, $d, $cc
11190c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11200c1bc742181ded4930842b46e9507372f0b1b963James Dong
11210c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11220c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL0T  $a, $b, $c, $d, $cc
11230c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBT, SMLALTT, $a, $b, $c, $d, $cc
11240c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11250c1bc742181ded4930842b46e9507372f0b1b963James Dong
11260c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11270c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL10  $a, $b, $c, $d, $cc
11280c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTB, SMLALBT, $a, $b, $c, $d, $cc
11290c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11300c1bc742181ded4930842b46e9507372f0b1b963James Dong
11310c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11320c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL11  $a, $b, $c, $d, $cc
11330c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTT, SMLALBB, $a, $b, $c, $d, $cc
11340c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11350c1bc742181ded4930842b46e9507372f0b1b963James Dong
11360c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11370c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL1B  $a, $b, $c, $d, $cc
11380c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTB, SMLALBB, $a, $b, $c, $d, $cc
11390c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11400c1bc742181ded4930842b46e9507372f0b1b963James Dong
11410c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11420c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLAL1T  $a, $b, $c, $d, $cc
11430c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTT, SMLALBT, $a, $b, $c, $d, $cc
11440c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11450c1bc742181ded4930842b46e9507372f0b1b963James Dong
11460c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11470c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLALB0  $a, $b, $c, $d, $cc
11480c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBB, SMLALBT, $a, $b, $c, $d, $cc
11490c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11500c1bc742181ded4930842b46e9507372f0b1b963James Dong
11510c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11520c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLALB1  $a, $b, $c, $d, $cc
11530c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALBT, SMLALBB, $a, $b, $c, $d, $cc
11540c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11550c1bc742181ded4930842b46e9507372f0b1b963James Dong
11560c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11570c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLALT0  $a, $b, $c, $d, $cc
11580c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTB, SMLALTT, $a, $b, $c, $d, $cc
11590c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11600c1bc742181ded4930842b46e9507372f0b1b963James Dong
11610c1bc742181ded4930842b46e9507372f0b1b963James Dong        MACRO
11620c1bc742181ded4930842b46e9507372f0b1b963James Dong        SMLALT1  $a, $b, $c, $d, $cc
11630c1bc742181ded4930842b46e9507372f0b1b963James Dong        LIBI4 SMLALTT, SMLALTB, $a, $b, $c, $d, $cc
11640c1bc742181ded4930842b46e9507372f0b1b963James Dong        MEND
11650c1bc742181ded4930842b46e9507372f0b1b963James Dong
11660c1bc742181ded4930842b46e9507372f0b1b963James Dong  ENDIF ;// ARMCOMM_S_H
11670c1bc742181ded4930842b46e9507372f0b1b963James Dong
11680c1bc742181ded4930842b46e9507372f0b1b963James Dong  END
1169