Home
The ARMSim# User Guide
Contents
1. 00 Display8Segment CKBLUELOOP ONE CI mov r0 5 SWI CLEAR LI mov mov BL r1 0 r0 1 bal Display8Segment CKBLUELOOP TWO mov swi r0 5 SWI CI EAR LI mov mov BL bal r1 0 r0 2 Display8Segment CKBLUELOOP THREE mov swi r0 5 SWI_CLEAR_LI mov mov BL bal r1 0 r0 3 Display8Segment CKBLUELOOP FOUR mov swi r0 5 SWI CLEAR LI mov mov BL r1 0 r0 4 Display8Segn CKBLUELOOP bal mov swi r0 5 SWI C nent LEAR LI Qclear Qclear Qclear Qclear Qclear Qclear previous previous previous previous previous previous line line line line line line ARMSim User Guide 43 ARMSim User Guide mov r1 0 mov r0 5 BL Display8Segment bal CKBLUELOOP SIX mov r0 5 Swi SWI CLEAR LINE mov r1 0 mov r0 6 BL Display8Segment bal CKBLUELOOP SEVEN mov r0 5 swi SWI CLEAR LINE mov r1 0 mov r0 7 BL Display8Segment bal CKBLUELOOP
2. cmp r2 r1 blt Roll rolled above 15 bits sub r5 r2 rl comput asy elapsed time bal CmpLoop Roll sub r5 r4 r1 compute rolled elapsed time add ESPES E2 CmpLoop cmp r5 r3 is elapsed time lt delay blt Wloop Continue with delay Xwait ldmfd sp r0 r5 pc data Welcome asciz Welcome to Board Testing LeftLED asciz LEFT light RightLED asci RIGHT light PressBlackL asciz Press a BLACK button Bye asciz Bye for now Blank asciz Non Digits word SEG A SEG B SEG C SEG D SEG E SEG G Q0 word SEG B SEG C Q1 word SEG A SEG B SEG F SEG EJ SEG D Q2 word SEG A SEG B SEG F SEG CISEG D 3 word SEG G SEG F SEG B SEG C Q4 word SEG A SEG G SEG F SEG C SEG D 5 word SEG A SEG G SEG FISEG EJ SEG D SEG C 6 word SEG A SEG B SEG C Q7 word SEG A SEG B SEG C SEG D SEG E SEG FISEG G G8 word SEG A SEG B SEG F SEG G SEG C 9 word 0 Blank display PressBlue asciz Press a BLUE button 0 9 only 15 tests InvBlue asciz Invalid blue button try again TestBlue asciz Tests z end 47
3. EofReached mov RO Stdout print last message ldr R1 EndOfFileMsg swi SWI PrStr Close a fil ldr RO InFileHandle Q get address of file handle ldr RO RO Q get value at address swi SWI Close Exit swiSWI Exit Q stop executing nFileError mov RO Stdout ldr R1 FileOpenInpErrMsg swi SWI PrStr bal Exit Q give up go to end data align InFileHandle Skip 4 InFileName asciz whatever txt FileOpenInpErrMsg asciz Failed to open input file An EndOfFileMsg asciz End of file reached n ColonSpace asciz NL asciz Ng cn new line Messagel asciz Hello World An end 11 3 Example Useful patterns for using SWI Instructions for a Plug In This is a possible initial template to set the useful SWI codes for the Embest Board Plug in egu SWI SETSEGS egu SWI SETLED egu SWI CheckBlack egu SWI CheckBlue egu SWI DRAW STRING egu SWI DRAW INT egu SWI CLEAR DISPLAY egu SWI DRAW CHAR egu SWI CLEAR LINE egu SW1I EXIT egu SWI GetTicks egu SEG A 0x80 egu SEG B 0x40 egu SEG C 0x20 egu SEG D 0x08 egu SEG E 0x04 egu SEG F 0x02 egu SEG G 0x01 egu SEG P 0x10 egu LEFT LED egu RIGHT LED 0x200 display on 8 Segment 0x201 LEDs on off 0x202 check Black button 0x203 check pre
4. 000053B0 00000000 000053B4 00000000 000053B8 00000000 000053BC 00000000 000053C0 00001240 000053C4 00001246 000053C8 00000000 000053CC 00000048 000053D0 000053F0 000053D4 000010AC 000053D8 00001240 000053DC 00001246 000053E0 00001240 000053E4 00001246 000053E8 00000000 000053EC 00000000 000053F0 00000000 000053F4 00001010 000053FC Top of the Stack Figure 11 Stack View 0000540C 00000000 Memory Address 6 5 Cache Views The Cache Views display the contents of the L1 cache The cache can have different organizations The one used by ARMSim can be selected by the user before an ARM program is executed The cache can consist of either a unified data and instruction cache displayed in the Unified Cache View or separate data and instruction caches displayed in the Data and Instruction Cache Views respectively depend ing on the cache properties selected by the user To set the cache properties select File Preferences and click the Cache tab Then use either the Cache Preferences Form see Figure 12 or the Cache Wizard to change the current cache settings and click OK To restore the default cache properties select the Restore Defaults button on the Cache Preferences Form When using the Cache Preferences Form to set the cache properties begin by selecting the type of cache Table 3 lists the available cache configurations Then se
5. to the lcd screen on line 10 display number of tests NG give only 15 tests message and clear the board column 1 mov r0 1 column number mov r1 10 Q row number ldr r2 Bye Q pointer to string swi SWI DRAW STRING draw to the LCD screen Turn off both LED s ldr r0 0 Swi SWI SETLED 8 segment blank mov x0 0 swi SWI SETSEGS8 ldr r3 2000 delay a bit BL Wait Clear the LCD screen swi SWI CLEAR DISPLAY swi SWI EXIT all done exit Display8Segment Number R0 Point R1 Displays the number 0 9 in RO on the 8 segment display If R1 1 the point is also shown Display8Segment stmfd sp r0O r2 1r ldr r2 Digits ldr rO r2 r0 1s142 tst rl 40x01 Gif r1 1 orrne r0 r0 SEG P then show P swi SWI SETSEG8 ldmfd sp r0 r2 pc Wait Delay r3 wait for r3 milliseconds Q Delays for the amount of time stored in r3 for a 15 bit timer Wait stmfd sp r0 r5 lr ldr r4 0x00007FFF mask for 15 bit timer SWI SWI GetTicks Get start time and r1 r0 r4 adjusted time to 15 bit Wloop SWI SWI GetTicks Get current time and r2 r0 r4 adjusted time to 15 bit 46 ARMSim User Guide
6. EIGHT mov r0 5 Swi SWI CLEAR LINE mov r1 0 mov r0 8 BL Display8Segment bal CKBLUELOOP NINE mov r0 5 Swi SWI CLEAR LINE mov r1 0 mov x0 9 BL Display8Segment bal CKBLUELOOP TEN mov x0 5 swi SWI CLEAR LINE mov x0 6 mov r1 5 ldr r2 InvBlue swi SWI DRAW STRING mov r1 0 mov r0 10 BL Display8Segment bal CKBLUELOOP ELEVEN mov r0 5 Swi SWI CLEAR LINE mov x0 6 mov r1 5 ldr r2 InvBlue swi SWI DRAW STRING Qclear Qclear Qclear Qclear OOo BD O Qclear previous previous previous previous previous column number row number pointer draw to the line line line line line to string LCD screen clear 8 segment clear previous line DO OOo column number row number pointer draw to the to string LCD screen r1 0 r0 10 Display8Segment CKBLUELOOP IW 0 5 II CLEAR LINI LH hour 0 46 1 4 2 InvBlue HB SWI DRAW STRING r1 0 r0 10 Display8Segment CKBLUELOOP THE r0 5 LH SWI CLEAR LINI r0 6 r1 5 r2 InvBlue SWI DRAW STRING r1 0 r0 10 Display8Segment CKBLUELOOP r0 5 SWI CLEAR LINE r0 6 r1 5 swi nov nov BL r2 InvBlue SWI D
7. clear all the cache statistics click the Reset button on the Cache Statistics display Note The Instruction Cache is sometimes referred to as the Code Cache UniFiedCacheView 3 0 30 3z E e59f003c e5900000 e59f1038 e5911000 00001010 e59f4034 e2405001 e3a06004 e0224695 25973028 e2500001 44000004 2511001 Cache Block 2 p 4a000002 e4124004 84334004 eafffff8 Memory Address nt K 00001040 ef000011 00001054 00001058 0000105c Cache block that was written to TYPO 2222P CYPP 2227 20222777 during the execution of the last instruction or sequence of 00001050 00001068 00000003 00000003 00000001 instructions 27727772 O 3 2277773 777707 0000 0T 00001060 00000002 00000003 00000003 00000000 Dirty Block T M T T T Y TTYYTY 0000007 M TT TPPYY T YYYYY O YTYTYYTYY 7 Y YT T PPP PP Figure 13 Cache View 7 Some ARMSim Limitations The ARMSim is an aid for learning the operation of the ARM architecture It does not implement every feature that can be found on the ARM Some of the more important limitations are listed below 20 ARMSim User Guide e The ARM architect
8. open ReverseCopy s Nhen the program 1s run execution stops just before execution of the instruction where the breakpoint is set A breakpoin Figure 6 Breakpoints 6 Additional Views In addition to the Code and Register Views discussed in sections 4 5 and 4 6 respectively ARMSim includes Watch Memory Output Stack and Cache Views that enable users to observe the data trans fers within the system as well as the output of the system The following sections describe these addi tional views and explain any commands and settings associated with them 6 1 Watch View The Watch View displays the values of variables that the user has added to the watch list which is a list of variables that the user wishes to monitor during the execution of a program 13 ARMSim User Guide To add a variable to the watch list select Watch gt Add Watch Alternatively right click in the Watch View and select Add Watch from the context menu In the Add Watch dialog box see Figure 7 select the file in which the variable appears the label that is attached to the variable and the display type of the variable If applicable specify the integer format of the variable and select the base in which the integer representation of the variable should be displayed Click OK To remove a variable from the watch list select the variable in the Watch View and then select Watch Remove Watch To remove all of the vari
9. 2 milliseconds Wait stmfdsp r0 r1 1r swi SWI_GetTicks mov ri r0 R1 start time WaitLoop swi SWI GetTicks subs r0 r0 rl RO time since start rsbltr0 r0 0 fix unsigned subtract cmp r0 r2 blt WaitLoop WaitDone ldmfdsp r0 rl pc 115 Example Subroutine to check for an interval with a 15 bit timer Embest Board The timer in ARMSim is implemented using a 32 bit quantity and the current time as number of ticks is accessed by using the SWI instruction with operand 0x 6d the corresponding EQU is set to be SWI GetTicks Itreturns in RO the number of ticks in milliseconds On the other hand the timer on the Embest board uses only a 15 bit quantity and this can cause a problem with rollover Assume one checks the time at a starting point T1 and then later at point T2 and one needs to test whether a certain amount of time has passe Ideally computing 12 11 and comparing it to the desired interval is enough The range in ARMSim with a 32 bit timer is between 0 and 232 1 4 294 967 295 As milliseconds this gives a range of about 71 582 minutes which is normally enough to ensure that one can keep checking the intervals T2 T1 without T2 ever going out of range in a single program execution The range in the Embest board with a 15 bit timer is between 0 and 21 1 32 767 giving a range of only 32 seconds When checking the interval T2 T1 there is no problem as long as T2 gt T1 and T2 lt 32 7
10. 30 students and staff only The topics in this document have been organized to provide a step by step introduction to ARMSim including the extra features regarding I O instructions based on custom SWI codes and plug ins The table of contents below summarizes the items described 1 Last updated July 2010 for ARMSim 191 ARMSim User Guide 10 11 Table of Contents OV CL VIC Wo sil laskou 1 Features pae EE 3 2 1 Mr 5 cee en o E ee a Eaa rakieta 3 2 2 VIEWS asta cutest Su bce cde o P RU SEEN IER ERAN 3 Settings up the Simulator sis ME 6 31 Docking Windows entere P Pe etre ener ee 6 3 2 Board Controls View the plug ins and the SWI instructions sss 7 3 3 BONS A IR Ies Te oe de Doe Tain ig aed 7 3 4 GCOoloUESi sinu e iive 7 Getting Started pec 7 4 1 Creating a Elle eae HERE enel n o REN ER ee E P S 7 4 2 Opening and Loading a File tetro sln 7 4 3 RUB A PROSTATE coc ete nee AR e c one s 8 4 4 Stopping a Program asc oe eet D a a en hie ete Ae ha ed rem EROR ES 8 4 5 Code VIeW ic eR li RR TRO ERR REM 8 4 6 Registers VIEW its tee bibo ede ei e deo e dira Nat i Hl ih BN eerie 9 Debugging a Program P nn 10 5 1 Stepping Through a Program ete aa 10 5 2 Restarting a PrOBTaTn slas ha eee voa 10 5 3 Reloading a Program 2 uet erede or e i e en ehe ee ta pee 10 5 4 Opening Multiple Files as sas e ete e ERR ERR Rad Ea Sa ree dao 10 5 5 Break points esselen ises
11. 4 always goes in R3 e Any additional arguments are pushed onto the stack e The return value always goes in RO e The function is free to destroy the contents of RO R3 and R12 used as scratch That is the called function can use these registers for computations and does not restore their original values when the function exits e The function must preserve the contents of all other registers excluding PC of course Thus the C cross compiler implements the calling conventions Thus the version of the gcc cross compiler from Code Sourcery implements the calling conventions and treats RO R3 and R12 as caller save registers implying that it is the caller function responsibility to save them in the stack before the BL instruction and restore them after return 10 5 Example 2 for combining C and ARM Example 2 is a program with 3 files 1 ARM Main s contains the main initial program in ARM which calls the function Compute which is in the external file ARM Aux s The function Print is called by Compute yet it is included in the main ARM file ARM Main s 2 ARM Aux s contains the function Compute which calls the function Print included in the main ARM file ARM Main s 3 Mystery c contains the function Mystery called by Compute 11 Code Examples 11 1 Example Print Strings Characters and Integers to Stdout using SWI Instructions for I O PRINT STRINGS CHARACTERS INTEGERS TO STDOUT egu SWI PrChr 0x00 Writ
12. 67 However it can happen that T1 is obtained close to the top of the range and T1 subsequently has a value after the rollover thus T2 lt T1 It is not enough to flip the sign as the following examples show 39 ARMSim User Guide Let T1 1 000 and T2 15 000 Then T2 T1 14 000 gives the correct answer for the interval Subse quently let T1 30 000 and the later T2 2 000 afte the timer has rolled over If one simply calculates T2 T1 28 000 or even tries to get its absolute value the answer is incorrect The value for the interval should be 32 767 T1 T2 32 767 30 000 2 000 4 767 which represents the correct number of ticks which passed between T1 and T2 Two things need to be done for correct programming First of all the timing value obtained in 32 bits in ARMSim should be masked to be only a 15 bit quantity so that the code will work both in the simula tor and on the board Secondly the testing for the interval include a test for rollover egu Secl 1000 1 seconds interval egu PointlSec 100 0 1 seconds interval egu EmbestTimerMask Ox7fff Q 15 bit mask for timer values egu Topl5bitRange 0x0000ffff 215 1 32 767 text start mov r6 0 counting the loops not necessary ldr r8 Topl5bitRange ldr r7 EmbestTimerMask ldr r10 PointiSec SWI SWI GetTicks Get c
13. 697469 DADOZOBE 20736177 20746F6E 6E756F66 00000064 00001260 00000000 00000000 oooO O0000000 OO000000 OODOODDO QOOOODOOD OOO000000 00000064 00000004 00000001 Figure 8 Memory View When an instruction is executed using one of the step commands see section 5 1 or when a sequence of instructions is executed using the Debug Run option or the Continue button see section 4 3 any memory locations that were written to during the execution of the instruction s are highlighted after the execution of the instruction s has finished The properties of main memory including its starting address the stack area and the heap area can be customized to suit the user s preferences To change these properties select File Preferences and click the Main Memory tab Type in new values for the starting address stack area and heap area or use the arrow buttons beside each property to adjust the value of that property see Figure 9 Click OK and then reload the program see section 5 3 to refresh the Memory View s Notes e Ifa store STR instruction is executed but the value in memory does not change check the Cache Preferences to make sure that the Write Policy is not set to Write Back If it is set it to Write Through See section 6 5 for information on setting the Cache Preferences 15 ARMSim User Guide e The simulator can have multiple Memory Views each of which displays a different region of memory To ope
14. 6c Read Integer from a File r0 file handle r0 the integer SWI RdInt swi Ox6d Get the current time 10 the number of SWI Timer 8 1 1 Detailed Descriptions and Examples for SWI Codes for I O Display Character on Stdout swi 0x00 A character is a 1 byte entity The SWI used with equ SWI register r0 The lines of code below print the character labelled A to the Stdout followed by the new line character 0x00 instruction from the SWI table of the simulator normally PrChr 0x00 can print such a character to the stdout view when assigned to Note that the assignment of a character to a register needs the single left quote in the syntax for the immediate operand Displays one character in the output window Display String on Stdout swi 0x02 Displays a string in the output window See also the more general swi 0x69 below Halt Execution swi 0x11 Stops the program Allocate Block of Memory on Heap swi 0x12 Obtain a new block of memory from the heap area of the program space If no more memory is available the special result 1 is returned and the C bit is set in the CPSR mov r0 A swi PrChr mov r0 Nn swi PrChr ldr r0 MyString swi 0x02 MyString asciz Hello There n swi SWI_Exit mov r0 28 Qget 28 bytes swi SWI_MeAlloc ldr rl Address str r0 r1 Address word 0 22 ARMSim User Guide Deallocate All Heap Blocks swi 0x13 Causes all previously allocated blo
15. GUVic The ARMSim User Guide O R N Horspool W D Lyons M Serra Department of Computer Science University of Victoria 1 Overview ARMSim is a desktop application running in a Windows environment It allows users to simulate the execution of ARM assembly language programs on a system based on the ARM7TDMI processor ARMSim includes both an assembler and a linker when a file is loaded the simulator automatically assembles and links the program ARMSim also provides features not often found in similar applications They enable users both to debug ARM assembly programs and to monitor the state of the system while a program executes The monitoring information includes both cache states and clock cycles con sumed The purpose of this user guide is to explain how to use the tools and views provided by ARMSimf In this document a view is a window displayed by the ARMSim simulator that shows the state of some aspect of the program being run The scope of the document has been limited to the features of the simulator It does not cover ARM assembly pro gramming or computer architecture Users who are unfamiliar with these topics should consult other material some of which is listed in the references E ARMSimulator BE A ARMSimulator University of Victoria Produced by Dr Nigel Horspool Dale Lyons Dr Micaela Serra Department of Computer Science Copyright 2006 University of Victoria All rights reserved For use by CSC2
16. RAW STRING r1 0 r0 10 Display8Segment bal CKBLUELOOP FTE EN CKI EX d nov wi r0 5 LH nov nov ldr SWI CLEAR LINI r0 6 r1 5 swi nov nov BL r2 InvBlue SWI DRAW STRING r1 0 r0 10 Display8Segment ELOOP nov swi r0 10 SWI CLEAR LINE clear 8 segment clear previous line column number row number pointer to string draw to the LCD screen C ec D BD O clear 8 segment clear previous line column number row number pointer to string draw to the LCD screen CD c e O clear 8 segment clear previous line column number row number pointer to string draw to the LCD screen CD c e O clear 8 segment clear previous line column number row number pointer to string draw to the LCD screen CD c e O clear 8 segment clear previous line ARMSim User Guide 45 ARMSim User Guide r0 4 VI CI mov swi EAR clear previous line 0 1 4 2 TestBlue IT mov mov ldr swi mov mov uh M hu r0 1 r1 4 mov r2 r4 swi SWI DRAW I subs r4 r4 1 bne BLUELOOP Prepare to exit draw a message 0 IT NT lst DRAW STRI
17. Sp rO rl1 pc YES we do need this data inputs word0 1 2 3 4 5 6 1 gone ARM Main s main ARM routine for Example 2 print a blank character from data ldr r0 Blank ldrb r0 r0 RO char to print blank swi SWI PrChr print a second character to Stdout mov RO B RO char to print swi SWI PrChr print a new line as a character to Stdout ldr r0 NewL ldrb r0 r0 swi SWI PrChr print mov mov Swi print mov ldr RO Stdout rl 42 SWI PrI nt RO Stdout rl EOL an integer to Stdout RO char to print new line mode is Output view Q integer to print a new line as a string to Stdout mode is Output view end of line 36 ARMSim User Guide swi SWI PrStr SwiSWI Exit stop executing end of program data Messagel asciz Hello World EOL asciz yt NewL ascii Tiny Blank ascii Woe end 11 2 Example Open and close files read and print integers using SWI Instructions for I O OPEN INPUT FILE READ INTEGER FROM FILE PRINT IT CLOSE INPUT FILE equ SWI Open 0x66 open a file egu SW1 Close 0x68 close a file egu SWI PrChr 0x00 Write an ASCII char to Stdout equSWI PrStr 0x69 W
18. a file is opened and successfully assembled and linked its contents are displayed in the Code View as described above and the first instruction to be executed is highlighted When multiple files are opened see section 5 4 the file in which execution must start is displayed in the Code View with the first instruction highlighted The other files can be viewed by clicking on the tabs at the top of the Code View 4 6 Registers View The Registers View displays the contents of the 16 general purpose user registers available in the ARM processor as well as the status of the Current Program Status Register CPSR and the condition code flags the leftmost 4 bits of the CPSR as displayed below the condition code flags in the simulator Additionally the Vector Floating Point VFP registers are available for display in the tab labelled Float ing Point These registers represent the 32 Single Precision registers or the 16 Double Precision Regis ters of the VFP Note that these two sets of registers are overlapped The General Purpose Registers are selected by clicking on the General Purpose Registers tab in the Registers View The contents of the general purpose registers can be displayed in hexadecimal signed decimal or unsigned decimal formats Use the Hexadecimal Signed Decimal and Unsigned Decimal buttons at the top of the Registers View to switch between display formats see Figure 4 When an instruction is executed using one of the s
19. ables from the watch list select Watch gt Clear All Alterna tively right click in the Watch View and select Clear All from the context menu Notes e Although Remove Watch appears in the Watch menu this option has not yet been implemented The Watch View does not display arrays however it is possible to display the first item of an array by treating it as a scalar variable and adding it to the watch list as described above ES AddWatch Labels SubStringSearchS s digits Display As Integer Format dquote FoundMsg NotFoundMsg C Byte space STRING so soo Signed Stringb sg Word Base C Character Decimal C String C Hexadecimal DK Cancel Watc h View Labe Value tens 1000000000 Figure 7 Adding a Watch 6 2 Memory View A Memory View displays the contents of main memory In this view each row contains an address fol lowed by a series of words from memory see Figure 8 14 ARMSim User Guide Since the entire main memory cannot be displayed in a single Memory View each Memory View shows only a part of memory The address in the top left corner of the view specifies the word at which the part of memory displayed in the view begins and the size of the view determines the number of words displayed To display a different part of memory enter a hexadecimal address from 0 to FFFFFFFF into the text box in the top left corner of the Memory View Alternatively use the up and down
20. ance of ARMSim including the location font and colour of the views can be customized to suit the user s preferences When the simulator is closed the settings are remembered for next time the user starts up ARMSim The following sections describe how to customize ARMSimf s appearance 3 1 Docking Windows All views except the Code View appear in docking windows see Figure 2 Each window can be docked along any side of the application window or it can float above the application window In addi tion each docking window can be displayed or hidden and each displayed window has an auto hide option To move a docking window click the title bar of the window and drag the window to the desired loca tion If multiple views have been stacked within a single docking window select the tab with the desired view name from the tabs along the bottom of the docking window click this tab and drag it to the desired location To toggle a docking window between the show and hide states select the view name from the View menu Alternatively to hide a docking window that is currently displayed click the X in the top right corner of the docking window To toggle a docking window between the show and auto hide modes click the pin in the top right corner Fl ARMSim The ARM Simulator Dept of Computer Science File View Cache Debug Watch Help Docked Window in Floating Window Auto hide Mode Output View wesieisbes Ed tl Use e pin to
21. appropriately It may be easier to use a data declaration for an array of words and then index into it Each element can be initialized to contain the value representing a number by having the appropriate byte values ORed together equ SEG A 0x80 egu SEG B 0x40 egu SEG C 0x20 Use equ statements to set up the byte value equ SEG D 0x08 of each segment of the Display equ SEG E 0x04 egu SEG F 0x02 egu SEG G 0x01 egu SEG P 0x10 Figure 16 Possible data declaration for byte values for segments 29 ARMSim User Guide Digits word A possible data dec word laration for an array word of words which can word be indexed to obtain word the appropriate word value for a number word 0 9 to be dis word plaved word word word Figure 17 Possible data declaration forinteger patterns SEG A SEG B SEG C SEG D SEG E SEG G Q0 SEG B SEG C Q1 SEG A SEG B SEG F SEG E SEG D 2 SEG A SEG B SEG F SEG C SEG D Q3 SEG G SEG F SEG B SEG C Q4 SEG A SEG G SEG F SEG C SEG D 5 SEG A SEG G SEG F SEG E SEG D SEG C 6 SEG A SEG B SEG C Q7 SEG A SEG B SEG C SEG D SEG E SEG F SEG G 8 SEG A SEG B SEG F SEG G SEG C Q9 0 Blank display An example of a possible routine to display a number in the 8 segment Display using the declarations given above is shown in Figure 18 Register RO and R1 are input parameters where RO contains the integer to be disp
22. arrows beside the text box to select lower and higher memory addresses respectively The contents of memory can be dis played as 8 bit bytes 16 bit halfwords or 32 bit words Use the three buttons in the Word Size box in the top right corner of the Memory View to switch among the three display formats e address of the first word where the Word Size display of memory in this view begins pray f Y 8 SBit 16Bit 32Bit 3406004 E0224695 00001000 ES9F003C ES900000 E59F1035 ES911000 ES9F4034 E2405001 00001020 ES9F3028 E2500001 inda E2511001 oe 00001040 EF000011 00001054 00001060 00000002 00000003 00001080 E3403000 E5D14000 00001040 EAOO00002 E2811001 E E4014001 E1530004 14000001 EAFFFFFS E3A00000 ESBDS01E DODO10CO E3530000 02000003 Memory locations that were written to during the execution 0001 E3400028 EADO0000 E3A0002D of the last instruction or sequence of instructions 0001 BA000017 14000000 E3A06001 0004 44000006 EAOD00002 E0800004 00001140 E3500000 CADODOO E1A01000 E2855001 EAFFFFF3 E3550000 14000001 E3560001 s L60 1AFFFFE9 E3406001 sa Ud E DOO005 E4C20001 EAFFFFE4 ESDFO 040 ESC20000 Use these buttons to switch between the 8 bit 16 bit and 32 bit display modes B3001 EAFFFFF4 EGBDGD1E DOO 1EO 00989680 000F4240 00018640 00002710 000003E8 00000000 00000000 OOGODODO 6C65006F 5453006C 4744952 09736920 0A002200 20646E61 09000047 20736177 6E756F66 00001240 74612064 736F7020 6F
23. broutine Therefore if a program consists of multiple files and there is a branch from a subroutine in one file to a subroutine in another file executing the branch using Step Into also changes the file displayed in the Code View 5 2 Restarting a Program To restart a program click the Restart button on the toolbar or select Debug Restart Restarting a pro gram resets the registers cache and memory it sets the program counter to the address of the first instruction in the program and it highlights this instruction the next instruction to be executed 5 3 Reloading a Program To reload a program click the Reload button on the toolbar or select File Reload Reloading a pro gram loads a new copy of the file from the hard drive it resets the registers cache memory stack and watches it sets the program counter to the address of the first instruction in the program and it high lights this instruction the next instruction to be executed 5 4 Opening Multiple Files To open multiple files select File Open Multiple Then click the Add button in the MultiFileOpen dialog box navigate to the folder in which the files are stored and double click the file to be opened Repeat the three steps in the previous sentence until all of the files to be opened have been added to the list in the dialog box Then click OK to open the files When the files have been successfully opened the contents of the file that contains the start
24. cemere ede RU e UR te te te o eR OE ETE RI ird 11 PRIMA T 12 6 1 Watch View zs toit Tet r GT EE 12 6 2 Memory VIEW sita sloh HN IN ud 13 6 3 Output VIC Wis hots acaba ani hola ll E ni i 15 6 4 Stack VIEW ini lu e a alia v nr sees 16 6 5 Cache VIEWS sin oct RO ll n 17 Some ARMSim Limitations 00 au ROH 19 SWI Codes for I O in ARMSimf the first Plug in eee esee eese tntntntntn tata a ns tn tata atate toten atte 20 8 1 Basie SWI Operations for TO rrt fe oer reete e RP te ee t epe 20 8 1 1 Detailed Descriptions and Examples for SWI Codes for I O eese 21 SWI Operations for Other Plug Ins the Embest Board Plug In eee 25 9 1 Details and Examples for SWI Codes for the Embest Board Plug in sess 27 Combining Cand ARM Code mc ods soon N Eo Eroa siise iss 31 10 1 Compiling a Program with C and ARM nter nnntnnen 31 10 2 Compiling a C Program to ARM with Code Sourcery sse ees 32 10 3 Linking and Executing the Program in ARMSim sss eene ntes 33 10 4 ARM Parameter Passing Conventions sess e eren nnne nnn nennen 33 10 5 Example 2 for combining C and ARM sese nnne nnne 34 Code Examples aiin a eene e rata suctesosvecsscucedusstenssnepovnssenusbesbsnsstessteasececcvesbssussces asustentestotegasesvscustessstecrs 34 11 1 Example Print Strings Charact
25. cks of memory swi DAlloc in the heap area to be considered as deallocated thus allowing the memory to be reused by future requests for memory blocks Open File swi 0x66 Opening a file for input Assume the following in the data section InFileName asci Infilel txt InFileError asciz Unable to open input file n align InFileHandle word 0 The following lines of code open the file called Infilel txt for input and store its file handle returned in RO by the opening call into the appropriate memory location ldr r0 InFileName Q set Name for input file mov r1 40 mode is input swi SWI Open open file for input bcs InFileError Q if error ldr r1 InFileHandle load input file handle str r0 r1 save the file handle Thus to open a file for input one needs to load the address of the string containing the file name into RO set the input mode 0 into R1 and execute the SWI instruction with 0x66 as operand By testing the carry bit upon return using the BCS instruction one makes sure that the file has been opened properly otherwise a message should be printed and the program should exit Opening a file for output Assume the following in the data section OutFileName asciz Outfilel txt OutFileError asciz Unable to open output file n align OutFileHandle word 0 The following lines of code open the file ca
26. d linked 5 5 Breakpoints A breakpoint is a user defined stopping point in a program i e a point other than an SWI 0x11 instruc tion at which execution of a program should terminate When a program is being debugged break points are used to halt execution of the program at predefined points so that the contents of storage locations such as registers and main memory can be examined to ensure that the program is working correctly 12 ARMSim User Guide When a breakpoint is set and the program is run using either the Debug Run option or the Continue button see section 4 3 execution of the program stops just before execution of the instruction at which the breakpoint is set see Figure 6 To set a breakpoint double click the line of code at which the breakpoint should be set Alternatively step through the code to the line at which the breakpoint should be set and then select Debug Toggle Breakpoint When the breakpoint is set a large red dot appears in the Code View next to the address of the instruction at which the breakpoint was set To clear a breakpoint double click the line of code at which the breakpoint is set Alternatively step through the code to the line at which the breakpoint is set and then select Debug Toggle Breakpoint To clear all of the breakpoints in a program select Debug gt Clear All Breakpoints Note e Clear All Breakpoints clears the breakpoints in all files that are currently
27. e an ASCII char to Stdout equSWI PrStr 0x69 Write a null ending string equSWI PrInt 0x6b Q Write an Integer equStdout 1 Set output mode to be Output View equSWI Exit 0x11 Stop execution global start text Stare print a string to Stdout mov RO Stdout Q mode is Stdout ldr R1 Messagel load address of Messagel swi SWI PrStr Q display message to Stdout print a new line as a string to Stdout mov RO Stdout Q mode is Stdout ldr r1 EOL end of line swi SWI PrStr print a character to the screen mov RO A RO char to print swi SWI PrChr 35 ARMSimf User Guide File ARM Main s Main and Print Routines egu SWI Exit Ox11 Local Constants egu SWI PrintInt Ox6B egu SWI PrintChar 0x0 egu Stdout 1 egu EndInput 1 global gt start Exported Symbols global Print extern Compute Imported Symbols text main start ldr r0 inputs mov vl EndInput bl Compute MainEnd swi SWI Exit void Print RO value Prints stmfd Sp r0 r1 lr YES we do need this mov rl r0 Rl value to print RO argl mov rO Stdout print to console swi SWI PrintInt PrintInt R0 where Rl value mov rO 0x0A ASC new line character swi SWI PrintChar PrintChar R0 value ldmfd
28. e extension ARM object files can be generated from ARM assembly files or C source files and must be compiled according to the instructions in Section XX on C and ARM For details on ARM assembly program ming consult the references 4 2 Opening and Loading a File To open a file select File Load Then navigate to the folder in which the file is stored and double click the file to be opened When a file is opened it is automatically assembled if it is a source file and linked If the assembly and linking processes are successful the contents of the file appear in the 8 ARMSim User Guide Code View with the first instruction in the start or main subroutine highlighted If the contents of the file appear in the Code View but the first instruction is not highlighted one must check the Output View for compiler errors see section 6 3 Notes e The file to be opened must be a source s file or an object 0 file e If the file to be opened does not appear in the directory listing in the dialog box check to make sure that the appropriate file type has been selected e The source code cannot be edited in the Code View window but must be changed in the original text editor and then reloaded 4 3 Running a Program To run the program displayed in the Code View select Debug Run or click the Continue button on the toolbar see Table 1 The program runs until the simulator encounters a breakpoint see section 5 5 for an exp
29. e that the integer has been read properly 9 SWI Operations for Other Plug Ins the Embest Board Plug In The SWI codes numbered greater than 255 have special purposes They are mainly used for interaction with Plug in modules which can be loaded with the ARMSim simulator Table 5 provides a current list of these codes as they are used in the Embest Board Plug in View Examples of their use follow with illus trations of the corresponding component The use of EQU is strongly advised to substitute the actual numerical code values Examples of code is also provided at the end of the section A diagram representing schematically the features of the Embest board is shown in Figure 14 A 8 segment Two LED lights wo buttons for input display for output for output N Keyboard for input t Figure 14 A diagrammatic view of the available controls and displays on the Embest Board View There are 5 main components in this view available for programming 1 One 8 segment display output 2 Two red LED lights output 26 Two black buttons input Sixteen blue buttons arranged in a keyboard 4 x 4 grid input ARMSim User Guide One LCD display screen which is a grid of 40 columns by 15 rows of individual cells The coordi nates for each LCD cell are specified by a column row pair The top left cell has coordinates 0 0 while the bottom right cell has coordinates 39 14 Each cell can conta
30. ers and Integers to Stdout using SWI Instructions for I O 34 11 2 Example Open and close files read and print integers using SWI Instructions for I O 36 11 3 Example Useful patterns for using SWI Instructions for a Plug In sse 37 11 4 Example Subroutine to implement a wait cycle with the 32 bit timer sss 38 ARMSim User Guide 11 5 Example Subroutine to check for an interval with a 15 bit timer Embest Board 38 11 6 Example Using the SWI Instructions for a Plug In Embest Board View 39 ARMSim User Guide 2 Features The ARMSimf toolbar and views give the user access to a variety of tools to debug and monitor ARM assembly language programs The following sections describe the controls provided by the toolbar and the information displayed in the views 2 1 Toolbar The ARMSim toolbar provides easy access to many of the debugging features of the simulator especially those fea tures that allow the user to control the execution of a pro gram The functions of the buttons on the toolbar are summarized in Table 1 fel ARMSim The ARM Simulator Dept of C Cache Debug watch Help Table 1 Toolbar Buttons The Step Into button causes the simulator to execute the highlighted instruction and move to the next instruction in the program If the highlighted instruction is a subroutine call BL or BX instruction then the next highlighted instructi
31. estore the default background and highlight colours 3 4 Colours To change the background highlight colour in a view move the cursor into the view click the right mouse button and select Background Colour Highlight Colour from the context menu Then make the changes in the Color dialog box and click OK To restore the original background and highlight colours move the cursor into the view click the right mouse button and select Restore Defaults from the context menu Note that Restore Defaults will also restore the default font settings The use of the highlight colour depends on context For example in the Code and Stack Views it is used as a background colour on the highlighted line but in the Register and Cache Views it is used as a text colour for storage locations that have been written to 4 Getting Started Using ARMSim to simulate the execution of a program on an ARM processor involves two activities actually running the program and observing the output Sections 4 1 to 4 4 provide information on run ning programs with the simulator while sections 4 5 and 4 6 describe two of the views available in the simulator 4 1 Creating a File ARMSim accepts both ARM assembly source files that use the Gnu Assembler gas syntax and ARM object files generated by the Gnu tools provided with Cygwin or CodeSourcery ARM assembly source files can be created using any text editor e g TextPad and must be saved with a s filenam
32. in exactly one ASCII character Table 5 SWI operations greater than OxFF as currently used for the Embest board Plug In Opcode Description and Action Inputs Outputs swi 0x200 Light up the 8 Segment r0 the 8 segment Pattern The appropriate segments light Display see below in Figure 15 for up to display a number or a details character swi 0x201 Light up the two LEDs 10 the LED Pattern Either the left LED is on or the where right or both Left LED on 0x02 Right LED on 0x01 Both LEDs on 0x03 i e the bits in position O and 1 of r0 must each be set to 1 appropriately swi 0x202 Check if one of the Black None r0 the Black Button Pattern Buttons has been pressed where Left black button pressed returns 10 0x02 Right black button pressed returns 10 0x01 i e the bits in position 0 and 1 of r0 get assigned the appropri ate values swi 0x203 Check if one of the Blue None see below in Figure r0 the Blue Button Pattern see Buttons has been pressed 19 for details below in Figure 19 swi 0x204 Display a string on the r0 x position coordinate The string is displayed starting LCD screen on the LCD screen 0 39 r1 y position coordinate on the LCD screen 0 14 r2 Address of a null ter minated ASCII string Note x y 0 0 is the top left and 0 14 is the bot tom left The display is limited to 40 characters per line at the given position of the LCD scree
33. including the null terminator stored in memory Write Integer to a File swi 0x6b Converts the signed integer value passed in r1 to astring and writes that string to the file identified by the file handle passed in r0 Assumes that an output file has been opened and that its name is stored in OutFileName and its file handle is stored in OutFileHandle The lines of code on the right print the integer 42 contained in reg ister R1 to the opened output file CharArray TextString asciz Answer mov r0 41 ldr r1 Message swi 0x69 amp display message Message asciz Hello There n ldr r0 InFileHandle ldr r0 r0 ldr rl CharArray mov r2 80 swi 0x6a bos ReadError InFileHandle word 0 Skip 80 ldr ldr mov swi r0 OutFileHandle ro r0 r1 42 SWI_Print 25 ARMSim User Guide Note The special file handle value of 1 can be mov r0 1 used to write the integer to the Stdout output mov r1 99 window An example appears on the right swi 0x6b display 99 Read Integer from a File swi 0x6c Reads a signed integer from a file The file is ldr r0 InputFileHandle identified by the file handle passed in r0 The ldr r0 r0 result is returned in r0 swi 0x6c If a properly formatted number is not found in bes ReadError the input the C bit is set and r0 is unchanged By the integer is now in r0 testing the carry bit upon return using the BCS instruction one makes sur
34. lanation of breakpoints or an SWI 0x11 instruction to exit the execution or a fatal error 4 4 Stopping a Program To stop a program that is currently running select Debug Stop or click the Stop button on the toolbar see Table 1 When the program has stopped any storage locations in the Register Cache and Memory Views that have been written to since the program started running are highlighted 4 5 Code View The Code View displays the assembly language instructions of the program that is currently active Next to each instruction the simulator shows the memory address of the instruction and the binary rep resentation of the instruction separated by a colon and displayed in hexadecimal format see Figure 2 Mainas tartsWith o UUUI1000 E3A01D4E 101004 E59F220C ldr Use the tabs to select the file to be displayed in the Code View rl STRIHG r2 SUBSTRING 00001014 EF000011 SearchString 00001018 E92D403E stmfd r13 rl r5 r14 Mhe address of an instruction displayed in hexadecimal form 00001024 E5D14000 r Tr 00001028 E3540000 cmp r4 40x00 0000102C 2200005 0000103 E92D000F 00001034 E1A000C The binary representation of an instruction displayed in hexadecimal form 00001038 E 1401002 T 7 0000103C EB000088 bl StartsWith 00001040 E1A05000 mov r5 r0 00001044 E8BDOOOF ldmfd ri3 r0 r3j vi Figure 3 Code View ARMSim User Guide When
35. lator Dept General Purpose Floating Point Hexadecimal Unsigned Decimal Signed Decimal o 00000000 R1 00000000 R2 00000000 R3 00000000 RA 00000000 R5 00000000 R6 00000000 R7 00000000 R8 00000000 R9 00000000 R10 s1 00000000 R11 fp 00000000 R12 ip 00000000 R13 sp 00004800 R14 1r 00000000 R15 pe 00000000 CPSR Register Negative H 0 Zero Z 0 Carry C 0 Over flow 0 IRQ Disable 1 FIQ Disable 1 of Computer Science isl JU Mi A MemoryView2 00000000 l sei 00000000 E3A00001 0000000C E3A00D06 00000018 EBOOO01C 00000024 E59F1130 E59r114C EB000012 E1A02000 EF000069 nx Word Size EF000069 E3A01FC5 E3A00001 E3A01019 OutputView Console Stdin Stdout Stderr Loading assembly language file C cygwin home mserra Sieve SieveAl1 A Figure 1 Views ARMSim User Guide Table 2 ARMSim Views Code View Registers View It displays the assembly language instructions of the program that is cur rently open This view is always visible and cannot be closed It displays the contents of the 16 general purpose user registers available in the ARM processor as well as the status of the Current Program Status Reg ister CPSR and the condition code flags The contents of the registers can be displayed in hexadecimal unsigned decimal or signed decimal formats Additionally the conte
36. layed and R1 contains 1 to display the P segment or 0 otherwise Q Display8Segment Number RO Point R1 Displays the number 0 9 in RO on the LED 8 segment display If RI 1 the point is also shown 1 Display8Segment stmfd sp r0 r2 1r 2 ldr r2 Digits 3 ldr r0 r2 r0 1s1 2 4 tst r1 0x01 if rl l 5 orrne r0 r0 SEG P then show P 6 swi 0x200 Figure 18 A possible Display8Segment routine 7 ldmfd sp r0 r2 pc In line 3 register r O is assigned the byte value corresponding to the indexed element of the array digits from Figure 17 For example to display the number 3 after execution of line 2 the input register x0 should contain the integer value 3 and register r2 contains the address of the array Digits Then the computation implied by r2 r0 1s1 2 adds 12 bytes to the address currently in r2 i e roO shifted left by 2 positions which evaluates to 3 x 4 12 and loads the word in position 3 of the array namely word SEG A SEG B SEG F SEG CI SEG D In fact this uses the segments A B C D F to display the correct number In line 4 the content of r1 is tested If x1 1 then the segment P is added to the display with its value ORed with the previous ones in r0 30 ARMSim User Guide Set the two LEDs to light up swi 0x201 mov r0 1 0x02 swi 0x201 left LED on Light up the LEDs the left or the right or bo
37. ldr r3 3000 BL Wait Test the blue buttons 0 9 with pro number on 8 segmeni for 3 seconds Draw a message to inform user to p mov rO 2 swi SWI CLEAR LINE mov r0 6 mov r1 2 ldr r2 PressBlue Swi SWI DRAW STRING mov r4 16 BLUELOOP wait for user to press blue button mov r0 0 BB swi SWI CheckBlue cmp r0 0 beg BB cmp r0 BLUE KEY 15 beq FIFTEEN cmp r0 BLUE KEY 14 beq FOURTEEN cmp r0 BLUE KEY 13 beq THIRTEEN cmp rO 4BLUE KEY 12 beq IWELVE cmp r0 BLUE KEY 11 beq ELEVEN cmp r0 BLUE KEY 10 beq TEN cmp r0 BLUE KEY 09 beq NINE cmp rO 4BLUE KEY 08 beg EIGHT cmp rO 4BLUE KEY 07 beq SEVEN right button show turn on right led display on 8segment turn on LEFT led mpting then display If 9 invalid ress a blue button clear previous line 2 umber er to the column n row numb pointer draw to string LCD screen CO cO BD DB get button press into RO Q if zero no button pressed 42 O 00 0 a O A 0 AS 0 A i Dad 0 S 0 S 0 S o S jo S j j j j j lt U QS QOS Q S Q S Q S Q S mo swi mov mov BL bal r0 BLUE 06 05 04 03 02 L0
38. leFound at the end ldr rl OutFileHandle If the file is opened successfully a positive num str ro r1 ber the file handle is returned in r0 Otherwise Sao a result of 1 is returned and the C bit is set OutFileHandle word 0 InFileHandle word O InFileName asciz Infilel txt OutFileName asciz Outfilel txt Note The default location for the file is the same folder as the assembler source code file If another loca tion is desired a full path to the file location can be used For example the code shown below opens or creates a text file in the Windows Temporary directory ldrr0 PathName movr1 1 output mode SwiSWI Open PathName asciz C TEMP MyFile txt Close File swi 0x68 At the end of execution a file should be properly closed or else it may be inaccessible to other applica tions The following lines of code show how to close both the input and output files used as examples above Q load the file handle ldr r0 InFileHandle Closes a previously opened file Unless a file is us shite 2 swi SWI Close closed it often cannot be inspected or edited by another program e g TextPad CO aver ce prog e i ldr r0 OutFileHandle ldr ro r0 swi SWI_Close Write String to a File swi 0x69 Assume you have the following in your data section MatMsg asciz AnThis is the resulting matrix n 24 ARMSim User Guide Also assume that an output file has been opened as shown above and
39. lled Out filel txt for output and store its file han dle returned in RO by the opening call into the appropriate memory location ldr r0 0utFileName Q set Name for output file mov rl1 1 mode is output swi SWI Open Q open file for output bcs OutFileError Q if error ldr r1 0utFileHandle load output file handle Str 40 1 save the file handle Thus to open a file for output one needs to load the address of the string containing the file name into RO set the output mode 1 into R1 and execute the SWI instruction with 0x66 as operand By testing the carry bit upon return using the BCS instruction one makes sure that the file has been opened prop erly or else a message should be printed and the program should exit 23 ARMSimf User Guide Summary of the swi 0x66 file opening instruction ldr r0 InFileName mov r1 0 input mode swi SWI_Open Opens a text file for input or output The file bes NoFileFound name is passed via 10 Register r1 specifies the file ldr rl InFileHandle access mode If r1 0 an existing text file is to be str ro r1 opened for input If r1 1 a file is opened for out bane put if that file exists already it will be overwrit ldr r0 OutFileName ten otherwise a new file is created If r1 2 an mov r1 1 output mode existing text file is opened in append mode so swi SWI_Open that any new text written to the file will be added bes NoFi
40. ltiple files in Section 5 4 as com bining C and ARM code requires the loading of multiple files 10 1 Compiling a Program with C and ARM An example program shown below in Figure 20 is constructed from two files where the main program in file AddMain s is coded in ARM assembler and the other file called myAdd c is coded in C and contains a function In order to execute the program in ARMSim the file myAdd c must first be com piled to ARM assembly source file myAdd s or to ARM object code myAdd o This can be accom plished using a cross compiler 32 ARMSim User Guide 1 File AddMain s 2 text 3 global start 4 extern myAdd 5 start 6 7 8 9 LDR RO Numi LDR RO RO first parameter passed in RO LDR R1 Num2 5 LDR R1 R1 second parameter passed in R1 10 BL myAdd RO myAdd Num1 RO Num2 R1 11 LDR R4 Answer 12 STR RO R4 result was returned in R 13 SWI 0x11 14 data 15 Numl word 537 16 Num2 word 237 17 Answer wordO 18 end VIII UA i N 1 File myAdd c 1 2 3 int myAdd int argl int arg2 4 int result argl arg2 5 return result 6 i Figure 20 Mixed ARM Assembler and C Program example 1 10 2 Compiling a C Program to ARM with Code Sourcery CODESOURCERY The Code Sourcery tool chain can be used for cross compiling and a non professional version is avail able for download fr
41. lumn shows the EQU patterns used thoughout this document in the examples Table 4 SWI I O operations 0x00 OxFF Opcode Description and Action Inputs Outputs EQU swi 0x00 Display Character on r0 the character SWI PrChr Stdout swi 0x02 Display String on r0 address of a null ter see also 0x69 Stdout minated ASCII string below swi 0x11 Halt Execution SWI Exit swi 0x12 Allocate Block of Mem r0 block size in bytes r0 address of block SW1 MeAlloc ory on Heap swi 0x13 Deallocate All Heap SWI DAlloc Blocks swi 0x66 Open File 10 file name i e address of rO file handle SWI Open mode values in r1 are 0 a null terminated ASCII If the file does not for input 1 for output 2 string containing the name open a result of 1 for appending r1 mode is returned swi 0x68 Close File r0 file handle SWI Close swi 0x69 Write String to a File or r0 file handleor Stdout SWI PrStr to Stdout r1 address of a null termi nated ASCII string 21 ARMSim User Guide Table 4 SWI I O operations 0x00 OxFF ticks ticks milliseconds Opcode Description and Action Inputs Outputs EQU swi 0x6a Read String from a File r0 file handle r0 number of SWI RdStr r1 destination address bytes stored 12 max bytes to store swi 0x6b Write Integer to a File r0 file handle SWI PrInt r1 integer swi 0x
42. n 27 ARMSim User Guide Table 5 SWI operations greater than 0xFF as currently used for the Embest board Plug In Opcode Description and Action Inputs Outputs swi 0x205 swi 0x206 Display an integer on the LCD screen Clear the display on the LCD screen 10 x position coordinate on the LCD screen 0 39 r1 y position coordinate on the LCD screen 0 14 r2 integer to print Note x y 0 0 is the top left and 0 14 is the bot tom left The display is limited to 40 characters per line None The string is displayed starting at the given position of the LCD screen Blank LCD screen swi 0x207 Display a character on the LCD screen r0 x position coordinate on the LCD screen 0 39 r1 y position coordinate on the LCD screen 0 14 r2 the character Note x y 0 0 is the top left and 0 14 is the bot tom left The display is limited to 40 characters per line The string is displayed starting at the given position of the LCD screen swi 0x208 Clear one line in the dis play on the LCD screen r0 line number y coordi nate on the LCD screen Blank line on the LCD screen 9 1 Details and Examples for SWI Codes for the Embest Board Plug in Set the 8 Segment Display to light up swi 0x200 The appropriate segments light up to display a number or a character The pattern of segments to be lit up is assigned to register RO bef
43. n additional Memory Views select View gt Memory When the display size is set to 8 bit the ASCII representation of each row of bytes is displayed at the end of the row When the display size is 16 bit or 32 bit the assignment of byte addresses is little endian Inthe Memory View all cells that are part of the memory region allocated to the program are shown in hexadecimal notation e g E1A03000 00000000 cells outside the allocated memory region are shown as question marks e g m PreferencesForm General Main Memory Cache Starting Address of Main Memory Stack Area KB Heap Area KB Memory Fill Pattern 81818181 Stop program on misaligned memory access Cancel OK Figure 9 Main Memory Preferences Form 6 3 Output View The Output View contains a row of two tabs labelled Console and Stdin Stdout Stderr Selecting the tab labelled Console brings a window to the front where the simulator outputs success and error mes sages After the simulator has loaded the program any assembler or linker errors are displayed here see Figure 10 for an example To find the source of an error message displayed in the Output View see Fig ure 10 double click the message and scroll up one line in the Code View Additional information will be displayed here such as instruction counts and runtimes Selecting the tab labelled Stdin Stdout Stderr brings a window to the front where output f
44. nd turn off RIGHT led mov rO 4LEFT LED swi SWI SETLED draw a message to the lcd screen on line 2 column 4 mov r0 4 column number mov r1 2 row number ldr r2 LeftLED pointer to string swi SWI DRAW STRING draw to the LCD screen Wait for 3 second ldr r3 3000 BL Wait turn on RIGHT led and turn off LEFT led mov r0 RIGHT LED swi SWI SETLED draw a message to the lcd screen on line 2 column 4 mov r0 4 column number mov r1 2 row number Lar r2 RightLED pointer to string swi SWI DRAW STRING draw to the LCD screen Wait for 3 second ldr r3 3000 BL Wait turn on both led mov rO 4 LEFT LED RIGHT LED swi SWI SETLED clear previous line 2 mov rO 2 swi SWI CLEAR LINE draw a message to inform user to press a black button mov r0 6 column number mov r1 2 Q row number ldr r2 PressBlackL 8 pointer to string swi SWI DRAW STRING draw to the LCD screen Qwait for user to press a black button mov r0 0 LB1 swi SWI CheckBlack get button press into RO cmp r0 0 beg LB if zero no button pressed cmp r0 RIGHT BLACK BUTTON 41 ARMSim User Guide bne LD1 ldr r0 SEG B SEG C SEG F swi SWI SETSEG8 mov r0 RIGHT LED swi SWI SETLED bal NextButtons LD1 left black pressed ldr r0 SEG G SEG E SEG F swi SWI SETSEG8 mov rO 4LEFT LED swi SWI SETLED NextButtons Wait for 3 second
45. nts of the Vector Floating Point Coprocessor VFP registers can be displayed They include the overlapped Single Precision Registers s0 s31 and the Double Precision Floating Point Registers d0 d15 Output View Console It displays any automatic success and error messages produced by the sim ulator Output View It displays any text printed to standard output Stdout Stdin Stdout Stderr Stack View It displays the contents of the system stack In this view the top word in the stack is highlighted Watch View It displays the values of variables that the user has added to the watch list that is the list of variables that the user wishes to monitor during the execu tion of a program Cache Views They display the contents of the L1 cache This cache can consist of either a unified data and instruction cache displayed in the Unified Cache View or separate data and instruction caches displayed in the Data Cache and Instruction Cache Views respectively depending on the cache properties selected by the user Board Controls View It displays the user interfaces of any loaded plug ins If no plug ins were loaded at application start this view is disabled Memory View It displays the contents of main memory as 8 bit 16 bit or 32 bit words There can be multiple memory views each displaying a different region of memory ARMSim User Guide 3 Setting up the Simulator The appear
46. oint Registers can be viewed as Single Precision or Double Precision registers Use the Sin gle Precision or Double Precision tabs at the top of the Registers View to switch between the display types see Figure 5 5 Debugging a Program ARMSim provides a number of features that enable users to debug ARM assembly programs includ ing execution controls to step through and restart programs Reload and Open Multiple commands and breakpoints Sections 5 1 and 5 2 describe the execution controls Sections 5 3 and 5 4 describe the Reload and Open Multiple commands respectively and section 5 5 explains how to manage break points 5 1 Stepping Through a Program To step through a program one instruction at a time use either the Step Into button or the Step Over button on the toolbar or alternatively select Debug Step Into or Debug Step Over After an instruction has been executed using either Step Into or Step Over both the next instruction to be executed and any memory locations in the Registers Memory and Cache Views that were written to during the execution of the instruction are highlighted For most instructions the results of both Step Into and Step Over are identical however when an instruction is a branch to a subroutine Step Into executes the branch and moves to the first instruction of the subroutine In contrast the Step Over executes the whole subroutine and moves to the instruction after the branch in the original su
47. om the site Code Sourcery G Lite Edition for ARM http www codesourcery com sgpp lite arm portal subscription template lite The most useful commands have also been linked into TextPad tools for easy use and both paths are shown here The examples assume that Code Sourcery has been installed in the directory C Program Files CodeSourcery All the commands below thus imply the prefix C Program Files CodeSourcery Sourcery G Lite bin 1 Inacmd window enter the command 33 ARMSim User Guide arm non abi gcc ex Wall S mcpu arm7tdmi myAdd c Or from TextPad use Tools C gt ARM Assembly s If there are no errors in the C program the cross compiler will create an ARM assembly file named myAdd s The S flag tells gcc to stop after the step of translating to assembly language 2 To generate simpler code one should try the optimizer with arm non abi gcc ex Wall S O1 mcpu arm7tdmi myAdd c corresponding in TextPad to Tools C gt ARM Assembly Optimize L1 s or with arm non abi gcc ex Wall S 02 mcpu arm7tdmi myAdd c corresponding in TextPad to Tools C ARM Assembly Optimize L2 s 3 The ARM assembly file can now be converted to an object file with arm non abi as ex warn mcpuzarm tdmi myAdd s o myAdd o corresponding in TextPad to Tools ARM Assembly Binary o Similarly the main program in ARM can be converted from ARM assembly to an object file as in arm non abi as ex
48. on will be the first instruction of the subroutine M The Step Over button causes the simulator to execute the highlighted instruction and move to the next instruction in the current subroutine If the highlighted instruction is a subroutine call BL or BX instruction then the program is run until the subroutine returns Thus unless a breakpoint is encountered the next highlighted instruction will be at the return point from the subroutine call 1 lil The Stop button causes the simulator to stop the execution of the program The Continue button causes the simulator to run the program until it encounters a breakpoint an SWI 0x11 instruction end of execution or a run time error The Restart button causes the simulator to start the execution of the program from the begin ning The Reload button causes the simulator to load a new version of the program file from the hard drive and start the execution of the program from the beginning ej Le el 2 2 Views The ARMSim views display the simulator s output and the contents of the system s storage ARMSim provides several views as shown in Figure 1 and summarized in Table 2 All views are enabled by selecting the appropriate item from View menu above the toolbar All views except the Code View appear in docking windows see Figure 2 Their placement and movement is described below ARMSim User Guide fe ARMSim The ARM Simu
49. or main subroutine will appear in the Code View with the first instruction in this subroutine highlighted To remove a file from the list of files to be opened select the filename in the dialog box and click the Remove button To remove all of the files from the list of files to be opened click the Clear button 11 ARMSim User Guide Registersview General Purpose Floating Point mecs cae lo 23514159 di Aue 28319 Use these buttons to switch between the Single or Double precision Floating Point Registers BN that were written d3 F 71828 N during the execution of the last instruction or sequence A of instructions d 7 38901 d7 20 0855 FCPSR Register Negative N 0 Zero Z 0 Carry C Overflow V Stride Length E 0x00000000 Figure 5 Floating Point Registers View Condition Code Flags oooo FPCPSR Floating Point Current Program Status Notes The files to be opened must be ARM assembler source s files ARM object o files or a combi nation of source and object files If a file does not appear in the directory listing in the dialog box one must check that the appro priate file type has been selected If the contents of the file appear in the Code View but the first instruction is not highlighted check the Output View for compiler errors see section 6 3 When the file is opened it is automatically assembled if it is a source file an
50. ore the call to swi 0x200 Figure 15 shows the arrangements of seg ments and an example follows Each segment is logically labelled and its byte code is shown in the list in Table 6 For example in Figure 15 to display the number 3 segments A B C D and F must be illuminated The code to be assigned to RO is computed by the logical OR of the individual byte codes 28 ARMSim User Guide Figure 15 The Pattern for the 8 Segment Display A 66299 99 AN je Table 6 Segmen Example number 3 plus dot t byte values o P G B Display byte values lt J F v A 0x80 C B lox40 CD e C 0x20 As an example the number 3 plus the E C right hand dot would have a pattern P o value computed as the logical OR of the D 0x08 values of the segments A B C D EP to J form the integer 0x80 0x40 C D p E 0x04 0x20 0x08 0202 0x10 OxFA to be assigned to 10 F 0x02 G 0x01 Below some segments of code are shown as examples for the 8 segment Display The equ statements are useful for accessing the byte values associated with the labels of each segment as shown in Figure 15 An example of a possible declaration of data is also given in Figure 17 for the display of integers where the byte values representing a particular number are already ORed together within the array data structure and can be indexed
51. r Set C Random 256 j 16 j 16 E egi 1 E Round Robin Direct Mepped Write Policy Allocate Policy Write Through C Read Allocate c C Write Back Write Allocate Both Restore Defouks Cache Wizerd Cancel OK Figure 12 Cache Preferences Form 19 ARMSim User Guide In the Cache Views the boundaries of sets are marked by the blue square brackets along the left hand side of the view see Figure 13 Each row consists of a memory address followed by a cache block that shows the contents of the block at this address in memory When an instruction is executed using one of the step commands see section 5 1 or when a sequence of instructions is executed using the Debug Run option or the Continue button see section 4 3 any cache blocks that were written to during the execution of the instruction s are highlighted after the exe cution of the instruction s has finished When the Write Policy is set to Write Back a dirty block is marked by a red dot to the left of the row To clear all of the cache blocks select Cache Reset Resetting the cache purges all of the dirty blocks invalidates all of the cache blocks and sets all of the cache statistics to zero To purge all of the dirty blocks in the cache select Cache Purge This command has no effect unless the Write Policy is set to Write Back To view the cache statistics including the hit and miss rates select Cache Statistics To
52. rite a null ending string equSWI PrInt 0x6b Write an Integer equSWI Rdlnt 0x6c Read an Integer from a file egu Stdout 1 Set output target to be Stdout egu SWI Exit 0x11 Stop execution global start text tart print an initial message to the screen mov RO Stdout print an initial message ldr R1 Messagel load address of Messagel label swi SWI PrStr Q display message to Stdout Q Open an input file for reading if problems print message to Stdout and exit ldr r0 InFileName Q set Name for input file mov r1 0 mode is input swi SWI Open open file for input bcs InFileError Check Carry Bit C if 1 then ERROR Q Save the file handle in memory ldr rl InputFileHandle Q if OK load input file handle Str r r1 save the file handle Q Read integers until end of fil RLoop ldr r0 2InputFileHandle load input file handle ldr r0 r0 swi SWI_RdInt Q read the integer into RO bcs EofReached Check Carry Bit C if 1 then EOF reached print the integer to Stdout mov r1 r0 R1 integer to print mov RO Stdout target is Stdout swi SWI Print mov RO Stdout print new line ldr r1 NI swi SWI PrStr bal RLoop Q keep reading till end of file End of fil 37 ARMSim User Guide
53. rom the user program is displayed as a result of using software interrupts SWI instructions to perform I O Output directed to either the standard output or standard error Stdin Stdout are displayed in this 16 ARMSim User Guide tabbed window Any request to read from the standard input device Stdin causes the program to freeze until the input is provided on the keyboard that input is echoed in this tabbed window as well To copy text from the one of the Output View tabbed windows right click in the view and select Copy to Clipboard from the context menu To clear the contents of the Output View tabbed window right click in the tab and select Clear from the context menu 6 4 Stack View The Stack View displays the contents of the system stack In this view the memory address of a value and its binary representation are displayed on a single line separated by a colon and displayed in hexa decimal format Furthermore the top word in the stack is highlighted see Figure 11 Note that the sys tem stack is a full descending stack experiments Console Stain Stdout Stderr Loading assembly language file C ARMSim 150 testFiles experiment s The following assembler loader errors occurred File C ARMSim 150 testFiles experiment s Line 6 Column 10 Message Undefined symbol A1 End of assembler errors M Watchview IG Memoryviemo Figure 10 Error Message 17 ARMSim User Guide Stackview
54. ss Blue button 0x204 display a string on LCD 0x205 display an int on LCD 0x206 clear LCD 0x207 display a char on LCD 0x208 clear a line on LCD 0x11 terminate program Ox6d get current time patterns for 8 segment display byte values for each segment of the 8 segment display 0x02 0x01 bit patterns for LED lights 38 ARMSim User Guide egu LEFT BLACK BUTTON 0x02 bit patterns for black buttons egu RIGHT BLACK BUTTON 0x01 Qand for blue buttons equ BLUE KEY 00 0x01 button 0 egu BLUE KEY 01 0x02 button 1 egu BLUE KEY 02 0x04 button 2 egu BLUE KEY 03 0x08 button 3 egu BLUE KEY 04 0x10 button 4 egu BLUE KEY 05 0x20 button 5 equ BLUE KEY 06 0x40 button 6 equ BLUE KEY 07 0x80 button 7 egu BLUE KEY 00 1 lt lt 8 E button 8 different way to set egu BLUE KEY 01 1 lt lt 9 button 9 equ BLUE KEY 02 1 10 button 10 egu BLUE KEY 03 1 lt lt 11 button 11 egu BLUE KEY 04 1 12 button 12 equ BLUE KEY 05 1 13 button 13 equ BLUE KEY 06 1 lt lt 14 button 14 equ BLUE KEY 07 1 15 button 15 11 4 Example Subroutine to implement a wait cycle with the 32 bit timer Wait Delay r2 wait for r
55. t the size of the cache s Once the Cache Size has been set selecting a value for either the Block Size or the Number of Blocks causes the remaining set tings in the Cache Size box to assume the appropriate values so that the three properties satisfy the fol lowing equation Cache Size bytes Block Size bytes x Number of Blocks 18 ARMSim User Guide Next select the Associativity of the cache s If Set Associative is selected set the Blocks per Set and select a Replacement Strategy Finally select the Write and Allocate Policies for the Cache or Data Cache Table 3 Cache Configurations Configuration Settings Unified Data and Instruction Cache Enable the Unified Data and Instruction Cache Separate Data and Instruction Caches Disable the Unified Data and Instruction Cache and enable the Data Cache and the Instruction Cache Data Cache Only Disable the Unified Data and Instruction Cache and the Instruction Cache and enable the Data Cache Instruction Cache Only Disable the Unified Data and Instruction Cache and the Data Cache and enable the Instruction Cache No Cache Disable the Unified Data and Instruction Cache the Data Cache and the Instruction Cache General Main Memory Cache F Unified Data and Instruction Cache F Cache F Enabled Cache Size Associativity Replacement Strategy Cache Size Bytes Block Size Bytes Number of Blocks C Fully Associstive 1 Set Blocks Pe
56. tep commands see section 5 1 or when a sequence of instructions is executed using the Debug Run option or the Continue button see section 4 3 any reg isters and condition code flags that were written to during the execution of the instruction s are high lighted after the execution of the instruction s has finished Registersview Use these buttons to switch Registers R10 R15 are also labelled between the Hexadecimal Hexadecimal reigned Decima Unsigned Decimal and Table 3 Signed Decimal E x Signed Decimal display E modes R10 jsl stack limit 00001240 R2 00001246 R3 0000000 00000048 R11 fp frame pointer Registers that were 00000000 R12 ip intra procedure call scratch written to during the R7 00000000 execution of the last S pee cee instruction or R13 sp stack pointer R9 00000000 sequence of instruc R10 s1 00000000 CRIT fp 100005310 D tions R14 Il link register R12 ip 100000000 rani R15 pc program counter R14 1x 200000000 CRIS pc 200001010 Condition Overflow V Code Flags IRQ Disable FIQ Disable CPU Mode 10x000000d CPSR Current Program Status Register Figure 4 General Purpose Registers View 10 ARMSim User Guide The Floating Point Registers are selected by clicking on the Floating Point tab in the Registers View The Floating P
57. th mov r0 0x01 according to the value supplied by r0 swi 0x201 right LED on mov r0 40x03 swi 0x201 both LEDs on Check if one of the Black Buttons has been pressed swi 0x202 The call with swi 0x202 sets the content of r0 swi 0x202 as r0 2 if the left black button was pressed or cmp ro 40x02 r0 1 if the right black button was pressed Test beg ActOnLeftBlack ing 10 enables follow up actions bal ActOnRightBlack Check if one of the Blue Buttons has been pressed swi 0x203 After the call with swi 0x203 test the content swi 0x203 of r0 The number in r0 corresponds to the posi cmp r0 1 tion of the blue button as depicted in Figure 19 emp ro 2 For example if r0 2 then the blue button in cmp r0 3 position 2 was pressed The keypad with 16 blue m buttons as depicted in the board view BODE N Keyboard for input Ea They are arranged such that each button has a corresponding bit position in the 16 bit lower portion of a word in register RO after the call to swi 0x203 to poll the keypad The number labels placed in the figure which do not appear on the real keypad also represent the corresponding bit position as returned in RO When a button is pressed the corresponding bit is set For example when the button in position 1 is pressed the swi 0x203 instruction returns r0 0x02 thatis r0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 in binary
58. that its name is stored in Out FileName and its file handle is stored in OutFileHandle Then the following lines of code print the string lt nThis is the resulting matrix n to the output file opened as shown above The string is preceded and followed by a new line since the char acter Nn is embedded at the end of the string ldrr0 OutFileHandle8 load the output file handle ldrr0 r0 RO file handle ldrr1 MatMsg RI address of string SwiSWI PrStr output string to file Writes the supplied string to the current position ldr r0 OutFileHandle in the open output file The file handle passed in ldr r0 r0 r0 must have been obtained by an earlier call to ldr r1 TextString the Open File swi operation swi 0x69 bes WriteError Note The special file handle value of 1 can be used to write a string to the Stdout output win dow of ARMSimf giving the same behaviour as swi 0x02 A brief example appears on the right Read String from a File swi 0x6a Reads a string from a file The input file is identi fied by a file handle passed in RO R1 is the address of an area into which the string is to be copied R2 is the maximum number of bytes to store into memory One line of text is read from the file and copied into memory and a null byte terminator is stored at the end The line is trun cated if it is too long to store in memory The result returned in r0 is the number of bytes
59. toggie between tne snow ana W auto hide modes and use the X to hide the view WatchView Ise the tabs to select one iew from a stack of views IP Figure 2 Docking Windows ARMSim User Guide 3 2 Board Controls View the plug ins and the SWI instructions While ARMSim can be used completely on its own the extra features of plug ins and I O instructions can be extremely useful They have to be enabled explicitly even when installed at the same time Plug ins see below are seen as configurable additions to provide extra functionality normally as a graphical view of I O e g a board with buttons and lights One other very important extension is the use of pre selected SWI instructions to implement I O functionalities such as reading and writing from standardin put or output or files see below In order to enable these features click on File and Preferences and then select the tab Plugins The avail able modules as loaded in the ARMSim directory are listed and need to be checked for enabling 3 3 Fonts To change the font size style or colour of the text in a view move the cursor into the view click the right mouse button and select Font from the context menu Then make changes in the Font dialog box and click OK To restore the original font settings move the cursor into the view click the right mouse but ton and select Restore Defaults from the context menu Note that Restore Defaults will also r
60. ure supports both little endian and big endian access to memory The ARM Sim supports only the little endian format the same as the Intel architecture which hosts the ARMSim e The ARM architecture has a special mode of execution called Thumb mode which is intended for embedded system applications where memory is a scarce resource Each thumb instruction occupies only 2 bytes Thumb mode is not currently supported by ARMSim 8 SWI Codes for I O in ARMSim the first Plug in Plug ins have been used to extend the functionality of ARMSim in a modular fashion A full descrip tion of the Plug in designs is beyond the scope of this document The default installation of ARMSim comes with two Plug ins module extensions SWIInstructions and EmbestBoard The SWlIInstructions plug in implements SWI codes to extend the functionality of ARMSim for common I O operations and its use is detailed in this section Important Note All Plug ins have to be enabled explicitly by checking their option in the File gt Preferences menu and selecting the appropriate line from within the tab labelled Plugins 8 1 Basic SWI Operations for I O The SWI codes numbered in the range 0 to 255 inclusive are reserved for basic instructions that ARM Sim needs for I O and should not be altered Their list is shown in Table 4 and examples of their use fol low The use of EQU is strongly advised to substitute the actual numerical code values The right hand co
61. urrent time Tl mov rti r0 Rl is Tl and rl rlysrY Tl in 15 bits RepeatTillTime add r6 r6 1 count number of loops not necessary SWI SWI GetTicks Get current time T2 mov r2 r0 R2 is T2 and D2 2 r T2 in 15 bits cmp E2 pel is T2 gt T1 bge simpletime sub r9 r8 rl TIME 32 676 T1 add r9 r9 r2 T2 bal CheckInt simpletime sub r9 r2 rl TIME T2 T1 CheckInt cmp r9 r10 Qis TIME lt interval blt RepeatTillTime Swi SWI EXIT end 11 6 Example Using the SWI Instructions for a Plug In Embest Board View Demonstration of Embest S3CI Q Assume the Clear the board clear swi SWI_CLEAR_DISPLAY Both LEDs off mov r0 0 swi SWI SETLED 8 segment blank E40 development board view EQU declaration from previous examples the LCD screen 40 ARMSim User Guide mov r0 0 swi SWI SETSEG8 draw a message to the lcd screen on lines1 column 4 mov r0 4 column number mov rl 41 row number ldr r2 Welcome pointer to string swi SWI_DRAW_STRING draw to the LCD screen display the letter H in 7segment display ldr r0 SEG B SEG C SEG G SEG E SEG F swi SWI SETSEG8 turn on LEFT led a
62. warn mcpu arm7tdmi AddMain s o AddMain o corresponding in TextPad to Tools ARM Assembly Binary o 4 Alternatively one can compile directly from C to ARM object code using arm non abi gcc ex c Wall mcpu arm7tdmi myAdd c o myAdd o corresponding in TextPad to Tools C gt ARM Binary o 10 3 Linking and Executing the Program in ARMSim At this point ARMSimf is able to combine the files into one program The four acceptable choices are listed below The MultiFileOpen dialog box should be used to load any of the combinations listed ARMSim loads and links the files after assembling if necessary ARMSimf is able to link and execute any of the above During the execution the focus in the code window shifts between modules as appro priate when a BL instruction is invoked 1 2 3 4 AddMain s AddMain s AddMain o AddMain o myAdd s myAdd o myAdd s myAdd o 10 4 ARM Parameter Passing Conventions The Gnu C compiler gcc can translate a function into code which conforms to the ARM procedure call standard or APCS for short when given the appropriate command line options The APCS rules are as follows 34 ARMSim User Guide e The first four arguments are passed in RO R1 R2 and R3 respectively If there are fewer argu ments then only the first few of these registers are used Thus parameter 1 always goes in RO parameter 2 always goes in R1 parameter 3 always goes in R2 parameter
63. where the bit in position 1 has been set Figure 19 The Pattern for the Blue Buttons 31 ARMSim User Guide Display a string on the LCD screen swi 0x204 mov r0 44 Display the string whose address is supplied in mov r1 1 r2 on the LCD screen at position x y where ldr r2 Message r0 x and r1 y In this example r0 4 and swi 0x204 display message r1 y 1 that is line 1 at column 4 Eid Message asciz Hello There n Display an integer on the LCD screen swi 0x205 mov r0 44 mov r1 41 mov r2 123 swi 0x205 display integer Display an integer on the LCD screen The inte ger is in r2 to be shown at position x y where r0 x and r1 y In this example r2 23 r 0 4 and r1 y 1 that is line 1 at column 4 displays 23 Clear the display on the LCD screen swi 0x206 Clear the whole LCD screen ENS ENS S SE en Display a character on the LCD screen swi 0x207 Display a character on the LCD screen The char mov r0 4 acter is in r2 to be shown at position x y mov r1 1 where here r0 x and r1 y In this example mov r2 4 Z r23 Z r0 4 and r1 y 1 that is line 1 at column swi 0x207 display char 4 displays Z Clear one line in the display on the LCD screen swi 0x208 Clear only one line on the LCD screen where the ldr r0 5 line number is given in r0 swi 0x208 clear line 5 10 Combining C and ARM Code It is useful first to review the instructions on opening and loading mu
Download Pdf Manuals
Related Search
Related Contents
初めてマニュアル(PDFファイル 1.49MB) TEFAL RE901601 Instruction Manual 取扱説明書 - MakeShop QTA Access Point Configurator User Manual ver 1.0 4082-12 manual FR Propiedades de Sorvall Legend XT / XTR イモビ対応アダプターBe Copyright © All rights reserved.
Failed to retrieve file