test-macros-trickbox.h.s
来自「OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI」· S 代码 · 共 2,561 行 · 第 1/5 页
S
2,561 行
;*******************************************************************************
;*
;* The confidential and proprietary information contained in this file may
;* only be used by a person authorised under and to the extent permitted
;* by a subsisting licensing agreement from ARM Limited.
;*
;* (C) COPYRIGHT 1994-1999 ARM Limited.
;* ALL RIGHTS RESERVED
;*
;* This entire notice must be reproduced on all copies of this file
;* and copies of this file may only be made by a person if such person is
;* permitted to do so under the terms of a subsisting license agreement
;* from ARM Limited.
;*
;* Validation Suite Macros and Definitions
;* =======================================
;*
;* Origin: ARM9 Validation Suite
;* Author: Jon Rijk 02/10/96
;* $Author: jrijk $
;* $Revision: 1.48 $
;* $Date: Mon Sep 10 15:16:51 2001 $
;*
;*******************************************************************************
;
; Description:
; PRINTF
; MESSAGE
; PART_MSG
; PHEX_REG
; PART_REG
; ANGEL_SWI
; SYS_ENTER_OS
; ENTER_SVC_MODE
; SYS_EXIT
;
; CYCLE_COUNT_BEGIN
; CYCLE_COUNT_END
; CYCLE_COUNT_READ
;
; SET_ABORT
; SET_RESET
; SCHEDULE_FIQ
; SCHEDULE_IRQ
; SCHEDULE_FIQ_AND_IRQ
; ASSERT_SE
; ASSERT_FIQ
; ASSERT_IRQ
; ASSERT_FIQ_AND_IRQ_AND_SE
; ASSERT_FIQ_AND_SE
; ASSERT_IRQ_AND_SE
; ASSERT_FIQ_AND_IRQ
; ASSERT_NWAIT
; STROBE_ABE
; STROBE_DBE
; STROBE_MSE
; SET_APE_HIGH
; SET_APE_LOW
; SET_PLLSLEE
; FIQ_STROBE_OFF
; IRQ_STROBE_OFF
; CLEAR_SE
; CLEAR_FIQ
; CLEAR_IRQ
; CLEAR_PLLSLEEP
;
;******************************************************************************
;--------------------------------------------------------------------------------
; Macro: [label] PRINTF <string>, [args]
;
; Function: behaves like a highly cut down version of C printf
;
; Parameters: [label] optional label
; <string> format string, supports:
; %x, %X - print arg in hex
; %d - print arg in dec
; %p - print arg in PSR format
; %s - print string ptr by arg
; %c - print char in arg
; [args] args as required by control string.
;
; Assumptions: Only a maximum of 6 args currently supported
; r0,r1 must be specified directly if they are args, PRINTF can't
; cope with register aliases
;--------------------------------------------------------------------------------
MACRO
$label PRINTF $string, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7
;OPT 32+8192 ; no vars and conditionals
[ "$arg7" /= ""
! 1, "PRINTF: Too many arguments (max 6)."
MEXIT
]
$label
[ VERBOSITY < VERBOSE_PRINTF
; put in a literal pool as a catch all for all outstanding literals
B %f1
LTORG
1
MEXIT
]
LOCAL
LCLL FROM_THUMB
[ {CODESIZE} = 16
; cope with entering in Thumb mode, switch to ARM
FROM_THUMB SETL {TRUE}
BX pc ; switch to ARM
CODE32
]
[ PC_BIT1SET
; clear bottom 2 bits of pc
BIC pc,pc,#3 ; clear bottom 2 bits
NOP ; pad due to pc being 2 inst ahead
]
; preserve r0,r14 and r1 if needed as a value for an arg and over the macro too
STR r0,store_r0$l
STR r14,store_r14$l
[ ANGEL
STR r1,store_r1$l
]
; declare vars
LCLS format ; remaining format string to parse
LCLS char ; current char being parsed
LCLS arg ; string value of current arg
LCLA scount ; current string count
LCLA acount ; current arg count
; assign initial values
format SETS "$string"
scount SETA 1
acount SETA 1
; define a new string (based on scount)
LCLS string$scount
; declare the number of args supported
LCLS arg00000001
LCLS arg00000002
LCLS arg00000003
LCLS arg00000004
LCLS arg00000005
LCLS arg00000006
; assign each arg its value
arg00000001 SETS "$arg1"
arg00000002 SETS "$arg2"
arg00000003 SETS "$arg3"
arg00000004 SETS "$arg4"
arg00000005 SETS "$arg5"
arg00000006 SETS "$arg6"
; main loop
WHILE :LEN:format > 0
; loop until conversion specifier or end of format string
WHILE :LEN:format > 0 :LAND: char /= "%"
char SETS format:LEFT:1 ; get next char
format SETS format:RIGHT:((:LEN:format)-1) ; shift format string
[ char /= "%" ; if not %
string$scount SETS string$scount:CC:char ; assign to current string
]
WEND
[ :LEN:string$scount = 1
; write char if string is just one char in length
arg SETS string$scount
string$scount SETS "" ; clear string
MOV r0,#'$arg'
[ ANGEL
STRB r0,temp$l
ADR r1,temp$l
ANGEL_SWI SWI_Angel_WriteC
|
SWI SWI_Demon_WriteC
]
|
[ :LEN:string$scount > 1
; else write current string if greater than one char in length
[ ANGEL
ADR r1,string$scount$l
ANGEL_SWI SWI_Angel_Write0
|
ADR r0,string$scount$l
SWI SWI_Demon_Write0
]
; increment count and declare new string
scount SETA scount + 1
LCLS string$scount
]
]
; decode conversion specifier
[ char = "%"
[ :LEN:format > 0
char SETS format:LEFT:1 ; get next char
format SETS format:RIGHT:((:LEN:format)-1) ; shift format string
; check for %%, as has no arg
[ char /= "%"
arg SETS arg$acount ; get value of current arg
[ "$arg" = ""
! 1, "PRINTF: null/bad argument, number $acount"
MEXIT
]
acount SETA acount + 1 ; increment for next arg
; get actual value of arg into reg, if r0,r1,r14 need to load from store
[ $arg = r0
LDR r0,store_r0$l
|
[ $arg = r14
LDR r0,store_r14$l
|
[ ANGEL :LAND: $arg = r1
LDR r0,store_r1$l
|
MOV r0,$arg
]
]
]
]
; parse conversion specifier
[ char = "x" :LOR:\
char = "X" ; if %x or %X write hex value
SWI SWI_WriteHex
|
[ char = "d" ; if %d write decimal value
SWI SWI_WriteDec
|
[ char = "p" ; if %p write PSR value
SWI SWI_WritePSR
|
[ char = "s" ; if %s write string pointed to by arg
[ ANGEL
MOV r1,r0
ANGEL_SWI SWI_Angel_Write0
|
SWI SWI_Demon_Write0
]
|
[ char = "c" :LOR:\
char = "%" ; if %c write char, if %% write %
[ ANGEL
[ char = "%"
MOV r1,#'%'
STRB r1,temp$l
|
STRB r0,temp$l
]
ADR r1,temp$l
ANGEL_SWI SWI_Angel_WriteC
|
[ char = "%"
MOV r0,#'%'
]
SWI SWI_Demon_WriteC
]
|
! 1, "PRINTF: Unknown conversion specifier '%$char', only %x, %X, %d, %s, %p, %c, %% supported."
MEXIT
]
]
]
]
]
|
! 1, "PRINTF: Bad string format ($string)"
MEXIT
]
]
char SETS "" ; null char for next iteration
WEND ; continue parsing format string
; restore r14 and r1 saved registers
LDR r14,store_r14$l
[ ANGEL
LDR r1,store_r1$l
]
[ FROM_THUMB
; if entered from Thumb, switch back to Thumb
ADR r0,thumb$l+1
BX r0
CODE16
thumb$l
]
; restore r0 saved registers (must be a forward ref to work in Thumb)
LDR r0,store_r0$l
B jump$l ; skip over string data
; put in a literal pool as a catch all for all outstanding literals
LTORG
; declare all the strings found whilst parsing format string
WHILE scount > 1
ALIGN
scount SETA scount - 1
format SETS string$scount ; get string into format
string$scount$l DCB "$format", 0 ; declare it
WEND
ALIGN
store_r0$l DCD 0 ; r0 arg value
store_r14$l DCD 0 ; r14 arg value
[ ANGEL
store_r1$l DCD 0 ; r1 arg value
temp$l DCD 0 ; temp value
]
ALIGN
jump$l LOCAL_END
MEND
;------------------------------------------------------------------------------
; Macro: [label] MESSAGE <string> [,<verbosity>]
;
; Function: Writes given string to 'stdout', with CR LF, only if verbosity
; level exceeds optional or default verbosity. All registers are
; preserved, PSR, other modes as affected by SWI_Write0.
;
; Internally: Calls PRINTF
;------------------------------------------------------------------------------
MACRO
$label MESSAGE $string, $verbosity
;OPT 32+8192 ; no vars and conditionals
[ "$string" = ""
! 1, "\n\n\tSyntax: [label] MESSAGE <string> [,<verbosity>]"
MEXIT
]
LCLA limit
[ "$verbosity" = ""
limit SETA VERBOSE_DEFAULT
|
limit SETA $verbosity
]
$label
[ VERBOSITY >= limit
[ :LNOT::DEF:OLD_MESSAGING
PRINTF "$string\n"
|
LOCAL
B jump$l
string$l DCB "$string\n", 0
ALIGN
store$l % 4
jump$l STR r0,store$l
ADR r0,string$l
SWI SWI_Demon_Write0
LDR r0,store$l
LOCAL_END
]
]
MEND
;------------------------------------------------------------------------------
; Macro: [label] PART_MSG <string> [,<verbosity>]
;
; Function: Writes given string to 'stdout', only if verbosity level exceeds
; optional or default verbosity. All registers are preserved, PSR,
; other modes as affected by SWI_Write0.
;
; Internally: Calls PRINTF
;------------------------------------------------------------------------------
MACRO
$label PART_MSG $string, $verbosity
;OPT 32+8192 ; no vars and conditionals
[ "$string" = ""
! 1, "\n\n\tSyntax: [label] PART_MSG <string> [,<verbosity>]"
MEXIT
]
LCLA limit
[ "$verbosity" = ""
limit SETA VERBOSE_DEFAULT
|
limit SETA $verbosity
]
$label
[ VERBOSITY >= limit
[ :LNOT::DEF:OLD_MESSAGING
PRINTF "$string"
|
LOCAL
B jump$l
string$l DCB "$string", 0
ALIGN
store$l % 4
jump$l STR r0,store$l
ADR r0,string$l
SWI SWI_Demon_Write0
LDR r0,store$l
LOCAL_END
]
]
MEND
;------------------------------------------------------------------------------
; Macro: [label] PHEX_REG <register> [,<verbosity>]
;
; Function: Writes the given register, in hex, to 'stdout', only if verbosity
; level exceeds optional or default verbosity. All registers are
; preserved, PSR, other modes as affected by SWI's.
;
; Internally: Calls PRINTF
;------------------------------------------------------------------------------
MACRO
$label PHEX_REG $reg, $verbosity
;OPT 32+8192 ; no vars and conditionals
[ "$reg" = ""
! 1, "\n\n\tSyntax: [label] PHEX_REG <register> [,<verbosity>]"
MEXIT
]
LCLA limit
[ "$verbosity" = ""
limit SETA VERBOSE_DEFAULT
|
limit SETA $verbosity
]
$label
[ VERBOSITY >= limit
[ :LNOT::DEF:OLD_MESSAGING
PRINTF "%x", $reg
|
LOCAL
B jump$l
store$l % 12
jump$l STR r0,store$l
STR r1,store$l+4
STR r2,store$l+8
MOV r1,$reg
MOV r2,#8
loop$l MOV r0,r1,LSR #28
MOV r1,r1,LSL #4
CMP r0,#10
ADDCC r0,r0,#"0"
ADDCS r0,r0,#"A"-10
SWI SWI_Demon_WriteC
SUBS r2,r2,#1
BGT loop$l
LDR r0,store$l
LDR r1,store$l+4
LDR r2,store$l+8
LOCAL_END
]
]
MEND
;------------------------------------------------------------------------------
; Macro: [label] PART_REG <register> [,<verbosity>, <characters>]
;
; Function: Writes the given register, in hex, to 'stdout', only if verbosity
; level exceeds optional or default verbosity. All registers are
; preserved, PSR, other modes as affected by SWI's. Only prints
; <characters> digits, starting with the least significant digit.
; Default is 8 digits
;
; Internally: Operates similar to PHEX_REG
;------------------------------------------------------------------------------
MACRO
$label PART_REG $reg, $verbosity, $characters
; ;OPT 32+8192 ; no vars and conditionals
[ "$reg" = ""
! 1, "\n\n\tSyntax: [label] PART_REG <register> [,<verbosity>, <characters>]"
MEXIT
]
LCLA limit
[ "$verbosity" = ""
limit SETA VERBOSE_DEFAULT
|
limit SETA $verbosity
]
LOCAL
$label
[ VERBOSITY >= limit
B jump$l
store$l % 12
jump$l STR r0,store$l
STR r1,store$l+4
STR r2,store$l+8
MOV r1,$reg
[ "$characters" = ""
MOV r2,#8
|
MOV r2,#$characters
MOV r1,r1,LSL #((8-$characters)*4)
]
loop$l MOV r0,r1,LSR #28
MOV r1,r1,LSL #4
CMP r0,#10
ADDCC r0,r0,#"0"
ADDCS r0,r0,#"A"-10
SWI SWI_Demon_WriteC
SUBS r2,r2,#1
BGT loop$l
LDR r0,store$l
LDR r1,store$l+4
LDR r2,store$l+8
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?