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