Training Script Language PRACTICE - Lauterbach

Transcription

Training Script LanguagePRACTICERelease 09.2021MANUAL

Training Script Language PRACTICETRACE32 Online HelpTRACE32 DirectoryTRACE32 IndexTRACE32 Training . Training Script Language PRACTICE .1E-Learning .5Ready-to-Run Scripts .5Introduction to Script Language PRACTICE .6Area of Use6Run a Script7Create a PRACTICE Script .9Convert TRACE32 Settings to a Script9Command LOG14Command History15Script Editor PEDIT16Syntax Highlighting18Debugging of PRACTICE Script .19Debug Environment20Display the PRACTICE Stack24PRACTICE Language .25Program RACTICE Flow Control .27Conditional Program Execution27Command List27Subroutine Calls32Command List32Example33GOTO/JUMPTO35Command List35Example36Script Calls38Command List 1989-2021 Lauterbach GmbH38Training Script Language PRACTICE 2

Example38PRACTICE Macros39Declare a Macro39Assign Content to a Macro41Macro Handling43Macros as Strings45Macros as Numbers47Note for Testing50More Complex Data Structures51Script Examples .52Run Through Program and Generate a Test Report52Check Contents of Addresses58Check Contents of Address Range59Check the Contents of Variables62Record Formatted Variables63Record Variable as CSV64Test Functions66Test Function with Parameter File67Parameter Passing .69Pass Parameters to a PRACTICE Script or to a Subroutine69PARAMETERS/RETURNVALUES vs. ENTRY77Operating System Interaction .82Operating System Detection82Printing Results83Accessing Environment Variables85Running a Command86File Manipulation87Time and Date Functions91I/O Commands .92Output Command92Input Command92I/O via the AREA Window94Event Control via PRACTICE96Simple Dialogs .97Dialog Programming .100Control Positioning103Control Properties105Enable or Disable a Control106Collect data from a control107Setting a value or state to a control110Execute a command111 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 3

File Browsing113Icons115Dialog Example116PRACTICE in a Multi-Core Environment .Communication via InterCom121122Designing Robust PRACTICE Scripts .124Path Functions and Path Prefixes125Host Operating System127Debug Hardware128Target CPU and Board129TRACE32 Version130TRACE32 Settings131Storing and Retrieving Settings133Robust Error Handling136Argument Handling138Creating a Custom Command139Common Pitfalls140 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 4

Training Script Language PRACTICEVersion 04-Nov-2021E-LearningVideos about the script language PRACTICE can be found here:https://www.lauterbach.com/tut practice.htmlReady-to-Run ScriptsReady-to-run PRACTICE scripts provided by the Lauterbach experts are published and updated daily here:https://www.lauterbach.com/scripts.html 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 5

Introduction to Script Language PRACTICEArea of UseThe main tasks of PRACTICE scripts are: To provide the proper start-up sequence for the development tool To automate FLASH programming To customize the user interface To store and reactivate specific TRACE32 settings To run automatic testsThe standard extension for PRACTICE scripts is.cmm. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 6

Run a ScriptCD.DO *// "*" opens a file browser for script// selection// TRACE32 first changes to the directory// where the selected script is located and// then starts the scriptChDir.DO filename Change to the directory where the script filename is locatedand start the script.DO filename Start script filename .PATH [ ] path name Define search paths for PRACTICE scripts.DO memtestChDir.DO c:/t32/demo/powerpc/hardwarePATH c:/t32/tests 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 7

It is possible to execute a PRACTICE script on startup of TRACE32. For details refer to “Automatic Startup Scripts” in PRACTICE Script Language User’s Guide, page 14 (practice user.pdf). 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 8

Create a PRACTICE ScriptConvert TRACE32 Settings to a ScriptThe commands STOre and ClipSTOre generate scripts that allow to reactivate the specified TRACE32 setting at any time. setting is in most cases the setup of a command group. setting SYStemSetting for command group SYStem.BreakSetting for command group Break.WinTRACE32 window configuration. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 9

Create a script to reactivate the current SYStem settings and store it to clipboardClipSTOre SYStemSYSTEM.RESETSYSTEM.CPU SPC56EC74SYSTEM.CONFIG.CORENUMBER 2.SYSTEM.CONFIG.CORE 1. 1.CORE.ASSIGN 1.SYSTEM.MEMACCESS NEXUSSYSTEM.CPUACCESS DENIEDSYSTEM.OPTION.IMASKASM OFFSYSTEM.OPTION.IMASKHLL OFFSYSTEM.BDMCLOCK 4000000.SYSTEM.CONFIG.TRISTATE OFFSYSTEM.CONFIG.SLAVE OFFSYSTEM.CONFIG.TAPSTATE 7.SYSTEM.CONFIG.TCKLEVEL 0.SYSTEM.CONFIG.DEBUGPORT Analyzer0SYSTEM.CONFIG.CJTAGFLAGS 0x3SYSTEM.MODE UP 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 10

Create a script to reactivate current Break settings and store it to clipboardClipSTOre ak.Setfunc24 /Programmain\38 /Programsieve /Program /Onchip /COUNT 1000.mstatic1; /WriteThe breakpoints are saved at a symbolic level by default. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 11

Create a script to reactivate the current window configurationSTOre window configuration.cmm Win /NoDate 1989-2021 Lauterbach GmbH//////////TRACE32 creates scriptwindow configurationto reactivate thecurrent windowconfigurationTraining Script Language PRACTICE 12

B::TOOLBAR ONSTATUSBAR ONFramePOS 15.625 8.9286 193. 47.WinPAGE.RESetWinPAGE.Create P000WinCLEARWinPOS 0.0 22.214 80. 5. 0. 0. W002Var.View %SpotLight.on %E flags %Open vtripplearrayWinPOS 0.0 31.429 80. 8. 5. 0. W003Frame /Locals /CallerWinPOS 0.0 0.0 80. 16. 13. 1. W000WinTABS 10. 10. 25. 62.List.autoWinPOS 84.25 0.0 77. 20. 0. 0. W004Register.viewWinPOS 83.875 24.071 105. 6. 0. 0. W001PER , "FlexCAN"WinPAGE.select P000ENDDO.Each PRACTICE script should end with an ENDDO instruction.ENDDO 1989-2021 Lauterbach GmbHReturn from PRACTICE script.Training Script Language PRACTICE 13

Command LOGThe LOG command allows users to create a record of most of the activities in the TRACE32 PowerViewGUI.Commands to control the LOG command:LOG.OPEN log file Create and open a file for the command LOG. The default extensionfor LOG files is (.log).LOG.CLOSEClose the command LOG file.LOG.OFFSwitch off command LOG temporarily.LOG.ONSwitch on command LOG.LOG.typeDisplay command LOG while recording.LOG.OPEN my log.log// Creates and opens the .log fileLOG.type// Displays .log file contents while recording // RecordingLOG.CLOSE// Closes .log fileContents of a command log:B::B::ListB::Go func24// B::LOG.ONB::B::PER , "Analog to Digital Converter"B::B::PER.Set.simple ANC:0xFFE00000 %L (d.l(ANC:0xFFE00000)& 0x40000000) 0x40000000 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 14

Command HistoryThe command history records only commands entered into the command line.The default extension for HISTory-files is (.log)HISTory.typeDisplay the command historyHISTory.SAVE [ file ]Save the command historyHISTory.SIZE [ size ]Define the size of the command historyBy default the script autostart.cmm contains the line:AutoSTOre , HISTorywhich automatically saves the command history in your temporary directory when you exit TRACE32 andrecalls the command history when you start TRACE32 again.AutoSTOre filename { setting } 1989-2021 Lauterbach GmbHStore defined settings automatically at the exit ofTRACE32 and reactivate them at the start of TRACE32Training Script Language PRACTICE 15

Script Editor PEDITCD.PEDIT *// "*" opens a file browser for script// selection// TRACE32 first changes to the directory// where the selected script is located and// then opens the script in a PEDIT windowChDir.PEDIT filename Change to the directory where the script filename is located andopen script in script editor PEDIT.PEDIT filename Open script filename in script editor PEDIT. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 16

In addition to a standard editor, PEDIT provides the ability to start or to debug a script.Save PRACTICE scriptSave PRACTICE script with a new nameClose and save PRACTICE scriptClose and do not save PRACTICE scriptSave and then start PRACTICE scriptStart PRACTICE scriptDebug PRACTICE script 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 17

Syntax HighlightingIn TRACE32, the PRACTICE script editor PEDIT provides syntax highlighting, configurable auto-indentation,multiple undo and redo.In addition to, or as an alternative to the built-in PRACTICE script editor PEDIT, you can work with anexternal editor. To configure syntax highlighting for PRACTICE scripts in an external editor, take these steps:1.Redirect the call of the TRACE32 editor EDIT to an external editor by using the TRACE32command SETUP.EDITEXT.2.Install the syntax highlighting files provided by Lauterbach for the external editor.EDIT filename Open file with standard TRACE32 editor.SETUP.EDITEXT ON command Advise TRACE32 to use the specified external editor ifthe EDIT command is used. command contains the command that TRACE32sends to your host OS to start the external editor. In thisstring the following replacements will be made: * will be replaced by the actual file name. # will be replaced by the actual line number.Lauterbach provides syntax highlighting files for some common text editors. Please refer to /demo/practice/syntaxhighlighting for details. stands for the trace32 installation directory , which is c:/T32 by default.// Instruct TRACE32 to use TextPad when the EDIT command is usedSETUP.EDITEXT ON "C:\Program Files (x86)\TextPad 5\TextPad.exe ""* (#)""" 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 18

Debugging of PRACTICE ScriptTRACE32 supports the debugging of PRACTICE scripts.A short video that provides an introduction into PRACTICE debugging is available on:https://www.lauterbach.com/tut practice.html 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 19

Debug EnvironmentUse Debug to start thedebugger for thePRACTICE scriptExplanation of the window header:WinResist.WinExt.PLISTDisplay the currently loaded PRACTICE script.WinResist: PEDIT window is not deleted bycommand WinCLEAR.WinExt: Detach PEDIT window from theTRACE32 main window - even if TRACE32 isoperating in MDI window mode. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 20

Command line commands:PSTEP filename Start script in PRACTICE debugger.ChDir.PSTEP filename TRACE32 first changes to the directory wherethe script is located and then starts the script inthe PRACTICE debugger.WinResist.WinExt.ChDir.PSTEP filename 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 21

Local buttons in PLIST/PSTEP windowStepSingle step PRACTICE script (command PSTEP).OverRun called PRACTICE script or PRACTICE subroutine as a whole(command PSTEPOVER).UpEnd current PRACTICE script or subroutine and return to the caller(command PSTEPOUT).ContinueContinue the execution of PRACTICE script (commandCONTinue).StopStop the execution of the PRACTICE script (command STOP).EnddoEnd the current PRACTICE script. Execution is continued in thecalling PRACTICE script. If no calling script exists, the PRACTICEscript execution is ended (command ENDDO).SkipSkips the current command or block (command PSKIP)MacrosDisplay the PRACTICE stack (command PMACRO.list).EditOpen PRACTICE editor PEDIT to edit the PRACTICE script(command WinResist.WinExt.PEDIT).BreakpointsOpen a PBREAK.List window to display all PRACTICEbreakpoints. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 22

Right-click for PRACTICEdebug-pull-downPRACTICE breakpointin this linePRACTICE debug-pull-downGoto TillRun PRACTICE script until the selected line (command CONTinue line number ).Set PC HereSet PRACTICE PC to the selected line.Breakpoint Open PBREAK.Set dialog to configure PRACTICE breakpoint.Toggle breakpointToggle PRACTICE breakpoint.Disable breakpointDisable PRACTICE breakpoint (command PBREAK.DISable).Edit HereOpen PRACTICE editor to edit the PRACTICE script. The cursor isautomatically set to the selected line. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 23

PRACTICE breakpoints can be set: to a specific line of a specified script to a specific line in any script (*)Display the PRACTICE StackDisplay the PRACTICE-StackThe PRACTICE stack displays the program nesting and the PRACTICE macros. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 24

PRACTICE LanguageSo far, we have seen that simple scripts can be created that can restore various settings to the currentdebug session. PRACTICE provides a lot more capability than this; it is a fully featured language with its ownsyntax and advanced features. This section will cover the language syntax, program elements, features andfunctions. Examples of PRACTICE scripts can be found in /demo/practice or athttps://www.lauterbach.com/scripts.htmlProgram ElementsCommentsComments start with // or ; and end with the next line break.Since the TRACE32 hll expression grammar allows ; to end an hll expression, ; has a special meaning forthe Var command group. Here a few examples.Var.View flags[3];ast.count;iVar.Break.Set flags[3]; /Write /VarCONDition (flags[12] 0)So to be safe it is recommended to use // to start a comment.CommandsThere are three types of commands that can be used in PRACTICE scripts: All TRACE32 commands which are also used interactively in the command line Commands for flow control and conditional execution of PRACTICE scripts. I/O commandsFunctionsFunctions are used to retrieve information about the state of the target system or the state of thedevelopment tool(s).Register( register name )Get the content of the specified CPU register.Var.VALUE( hll expression )Get the contents of an HLL expression. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 25

STATE.RUN()Returns true if program is running on the target, returns falseif program execution is stopped.OS.PresentWorkingDirectory()Returns the name of the current working directory as a string.CONVert.CHAR( value )Converts an integer value to an ASCII character.A list of all available functions can be found in the online help:Select functions onlyLabelsLabels have to be entered in the first column and they end with “:”. For more information on labels pleaserefer to the section on subroutines.It is recommended to avoid unnecessary blanks. Unnecessary blanks can leadto a misinterpretation of PRACTICE commands.&i 7.; unnecessary blanks can lead to; misinterpretations&i 7. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 26

PRACTICE Flow ControlConditional Program ExecutionCommand ListIF condition ( if block )ELSE( else block )Execute if block if condition is true. Execute else block otherwise. condition has to be specified in TRACE32 syntax.// Script double if.cmmPRIVATE &testfunc &correct resultOPEN #1 "func test.txt" /READWHILE TRUE()(READ #1 &testfunc &correct resultIF "&testfunc"! ""(IF Var.VALUE(&testfunc) &correct result(APPEND "test protocol.txt"\FORMAT.STRing("&testfunc &correct result",50.,' Set()))ELSE(PRIVATE &result&result CONVert.HEXTOINT(Var.VALUE(&testfunc))APPEND "test protocol.txt"\FORMAT.STRing("&testfunc failed with &result (&correct result)",50.,' Set())))ELSE(CLOSE #1ENDDO))ENDDO 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 27

If script lines are too long they can be split by adding a space and the ’\’ character at the end.To better understand the scope of PRACTICE macros given later in this training, it is important to know howTRACE32 maintains information on the PRACTICE stack.TRACE32 adds a new block-frame to the PRACTICE stack, whenever instructions are blocked by roundbrackets.PLISTList PRACTICE script that is currently being executed.PMACRO.listList PRACTICE stack. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 28

Var.IF hll condition ( if block )ELSE( if block )Execute if block if hll condition is true. Execute else block otherwise. hll condition has to be written in the syntax of the programminglanguage used.; Var.IF exampleVar.IF (flags[0] flags[5])PRINT "Values are equal."ELSEPRINT "Values do not match."ENDDOWHILE condition ( block )Execute block while condition is true.Var.WHILE hll condition ( block )Execute block while hll condition is true. 1989-2021 Lauterbach GmbH condition has to be specified in TRACE32 syntax. hll condition has to be written in the syntax of the programminglanguage used.Training Script Language PRACTICE 29

RePeaT count command Repeat command count -times.RePeaT count ( block )Repeat block count -times.RePeaT( block )WHILE condition Repeat the block whilst the condition evaluates to aboolean TRUE.;Example 1;Print the character X 100 timesAREA.viewRePeaT 100. PRINT "X";Example 2Var.Break.Set flags /Write//Set a Write breakpoint to array//flags;Repeat the following 10 times;Start the program and wait until the target halts at the breakpoint.;Then export the contents of array flags to file flags export.csv in CSV;format.RePeaT 10.(GoWAIT !STATE.RUN()Var.EXPORT "flags export.csv" flags /Append) 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 30

;Example 3;Read a line from my strings.txt;Write not-empty lines to file my strings noempty.txtPRIVATE &CurrentLine &RightLineOPEN #1 my strings.txt /ReadOPEN #2 my strings noempty.txt /CreateAREA.viewRePeaT(READ #1 %LINE &CurrentLineIF (FILE.EOFLASTREAD()&&("&CurrentLine"! ””))WRITE #2 "&CurrentLine")WHILE !FILE.EOFLASTREAD()CLOSE #1CLOSE #2 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 31

Subroutine CallsCommand ListGOSUB label [ parameter list ] ENDDO label ( block RETURN)NOTE:Call subroutine specified by label with anoptional set of paramters.Execute block and RETURN to caller.Labels must start in the first column of a line and end with a colon. Nopreceding white space allowed. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 32

Example// Script test func param.cmmLOCAL &testfunc &correct resultOPEN #1 func test.txt /READWHILE TRUE()(READ #1 &testfunc &correct resultIF "&testfunc"! ""(GOSUB perform test)ELSE(CLOSE #1ENDDO))ENDDOperform test:(IF Var.VALUE(&testfunc) &correct result(APPEND test protocol.txt\FORMAT.STRing("&testfunc &correct result",50.,' Set()))ELSE(PRIVATE &result&result CONVert.HEXTOINT(Var.VALUE(&testfunc))APPEND test protocol.txt\FORMAT.STRing("&testfunc failed with &result (&correct result)",50.,' Set()))RETURN) 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 33

TRACE32 adds a new gosub-frame to the PRACTICE stack whenever a subroutine is called. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 34

GOTO/JUMPTOCommand ListGOTO label Continue PRACTICE script at label . label must be part of the currently executing script.JUMPTO label Continue PRACTICE script at label . label must be part of a script that is currently located on thePRACTICE stack. label must not be located in a block.The PRACTICE stack is cleaned up accordingly. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 35

Example// Script test sequence.cmmDO target setup.cmmDO check boot.cmmENDDOterminate script:(DIALOG.OK "Script terminated by test failure"ENDDO)// Script check boot.cmmGo mainWAIT !STATE.RUN() 2.sIF STATE.RUN()(Break.direct)IF Register(PC) ADDRESS.OFFSET(main)(APPEND test protocol.txt FORMAT.STRing("System booted successfully",70.,' ') t()))ELSE(APPEND test protocol.txt FORMAT.STRing("Booting failed",70.,' ') t())JUMPTO terminate script)DIALOG.OK text 1989-2021 Lauterbach GmbHCreate a dialog that provides a text -message to the user. The scriptexecution is stopped until the user pushes the OK button in the dialog.Training Script Language PRACTICE 36

1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 37

Script CallsCommand ListDO script [ parameter list ]A script can be started from the command line orcalled within a script.Optional parameters can be passed to the script.Example// Script test sequence.cmmDO target setup.cmmDO check boot.cmmENDDOterminate script:(DIALOG.OK "Script terminated by test failure"ENDDO)TRACE32 adds a new do-frame to the PRACTICE stack whenever a script is started 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 38

PRACTICE MacrosMacros are the variables of the script language PRACTICE. They work as placeholders for a sequence ofcharacters.Macro names in PRACTICE always start with an ampersand sign (‘&’), followed by a sequence of letters (az, A-Z), numbers (0-9) and the underscore sign (’ ’). The first character after the & sign must not be anumber. Macro names are case sensitive, so &a is different from &A.Declare a MacroEmpty PRACTICE macros can be declared along with their scope by using one of the following PRACTICEcommands:PRIVATE { macro }Create PRIVATE macros.PRIVATE macros are visible in the script, subroutine or block in whichthey are created. And they are removed when the script, subroutine orblock ends.They are visible in nested blocks, but not in called subroutines andcalled scripts.LOCAL { macro }Create LOCAL macros.LOCAL macros are visible in the script, subroutine or block in whichthey are created. And they are removed when the script, subroutine orblock ends.They are visible in nested blocks, in called subroutines and calledscripts.GLOBAL { macro }Create GLOBAL macros.GLOBAL macros are visible to all scripts, subroutines and blocks untilthey are explicitly removed by the command PMACRO.RESet. Theycan only be removed if no script is running. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 39

What happens if a PRACTICE macro is used, but not declared?// Script test func param.cmmLOCAL &testfunc &correct resultOPEN #1 "func test.txt" /READWHILE TRUE()(READ #1 &testfunc &correct resultIF "&testfunc"! ""(GOSUB perform test)ELSE(CLOSE #1ENDDO))ENDDOperform test:(IF Var.VALUE(&testfunc) &correct result(APPEND "test protocol.txt"\FORMAT.STRing("&testfunc &correct result",50.,' Set()))ELSE(PRIVATE &result&result CONVert.HEXTOINT(Var.VALUE(&testfunc))APPEND "test protocol.txt"\FORMAT.STRing("&testfunc failed with &result (&correct result)",50.,' Set()))RETURN)The PRACTICE interpreter will implicitly declare a new LOCAL macro when an assignment is done andcannot find a macro of that name in the current scope.The command PMACRO.EXPLICIT advises the PRACTICE interpreter to generate an error if a PRACTICEmacro is used in an assignment, but was not declared in advance. It also advises the PRACTICE interpreterto generate an error if the same macro was intentionally created a second time within its scope. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 40

Assign Content to a Macro// ScriptPRIVATE &my string &my range &my varPRIVATE &my number &my float &my var value &my expressionPRIVATE &my boolean &my boolean result// Assign a string&my string "Hello World"&my range "0x40004000 0xfff"&my var Var.STRing(cstr1)// Assign a numbers&my number 100.&my float 5.667e13&my var value Var.VALUE(ast.count)&my expression &my number*&my var value// Assign a boolean&my boolean TRUE()&my boolean result STATE.RUN()ENDDOAfter a content is assigned to a macro, tooltips allows to inspect its current content. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 41

The PRACTICE stack provide an overview for all macros.The keyword PRIVATE is used to identify PRIVATE macros.Var.STRING( hll expression ) 1989-2021 Lauterbach GmbHReturns a zero-terminated string, if hll expression is apointer to character or an array of characters.Returns a string that represents the variable contentsotherwise.Training Script Language PRACTICE 42

Macro HandlingTo better understand the usage of macros, it is the best to look at the way the PRACTICE interpreterexecutes a script line.The PRACTICE interpreter executes a script line by line. Each line is (conceptually) processed in threesteps:1.All macros are replaced by their corresponding character sequence.2.All expressions are evaluated.3.The resulting command is executed.For the following examples the command PRINT is used.PRINT { data }PRINT specified data to TRACE32 message line and to TRACE32message area.Example 1PRIVATE &a&a "5 4"PRINT &aWe look at the PRINT &a line. To execute this line, the interpreter will first:1.Replace all macros with their corresponding character sequences. So:PRINT &a - PRINT 5 42.Evaluate all expressionsPRINT 5 4 - PRINT 93.Execute the resulting command. So it will execute PRINT 9. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 43

Example 2PRIVATE &a&a "Hello World"PRINT &aThis example will generate an error.Let’s look at the three steps the interpreter will take to execute the PRINT &a command:1.Replace all macros with their corresponding character sequencesPRINT &a - PRINT Hello World2.Evaluate expressionsPRINT Hello World - error3.Execute command, which will not happen because of the error in the second step.The second step fails because in PRACTICE a single word like Hello (which is not enclosed in doublequotes) refers to a debug symbol, loaded, for example, from an ELF file.When the PRACTICE interpreter encounters such a debug symbol, the expression evaluation will try toreplace the debug symbol by the address to which the symbol refers. If there is no debug symbol calledHello (which is likely), the PRACTICE interpreter will output the error message symbol not found.If by pure accident there are debug symbols called Hello and World the addresses of these symbols willbe printed.This example demonstrates how the pure macro replacement step will basically always work, since youalways can replace a macro by its character sequence; but the result might not make sense. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 44

Macros as StringsMacros are replaced by their character sequence. If you want to explicitly use this character sequence as astring, then you should enclose the macro in double quotes, for example:PRIVATE &a&a "Hello World"PRINT "&a"To understand what happens it is again best to look at the three steps which are taken to execute thePRINT "&a" command.1.Replace the macro by its character sequencesPRINT "&a" - PRINT "Hello World"2.Evaluate expressions.Nothing to do for this example.3.Execute command. 1989-2021 Lauterbach GmbHTraining Script Language PRACTICE 45

String composing example:// Script string example.cmmPRIVATE &drive &architecture &demo directory&drive "C:"&architecture "MPC"// PRINT commandPRINT "Directory " "&drive" "\T32 " "&architecture" "\demo"PRINT "Directory " "&drive" "\T32 " "&architecture" "\demo"PRINT "Directory &(drive)\T32 &(architecture)\demo"// Macro assignment&demo directory "&drive" "\T32 " "&architecture" "\demo"DIR &demo directory&demo directory "&(drive)\T32 &(architecture)\demo"DIR &demo directory// Command parameterDIR "&(drive)\T32 &(architecture)\demo"DIR directory 1989-2021 Lauterbach GmbHDisplay a list of files and folders for the specified directory.Training Script Language PRACTICE 46

Macros as Numbers// Script numbers.cmmPRIVATEPRIVATEPRIVATEPRIVATE&my hex &my dec &my bin&my stringlength &my sizeof&add1 &add2&convert1 &convert2// Hex, decimal, binary by TRACE32 syntax&my hex 0x7&my dec 22.&my bin 0y1110// Hex, decimal, binary as expression result&add1 &my bin &my hex&add2 &my hex &my dec// Hex, decimal, binary as return value&my stringlength STRing.LENgth("0123456789012345")&my sizeof sYmbol.SIZEOF(sieve)// Hex, decimal, binar

1989-2021 Lau terbach GmbH Training Script Language PRACTICE 9 Create a PRACTICE Script Convert TRACE32 Settings to a Script The commands STOre and ClipSTOre generate scripts that allow to reactivate the specified TRACE32 setting at any time. setting is in most cases the setup of a command group.