18
1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Embed Size (px)

Citation preview

Page 1: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

1

ARMSim# and SWIInstructions Plug-in

Group 11:

Brian Knight

Benjamin Moore

Alex Williams

Page 2: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Outline Overview of SWIInstructions Plug-in for

ArmSim# Basic SWI Operations for I/O Stdin/Stdout/Stderr View ArmSim# I/O Examples with SWI

Printing Characters Printing Strings Determining Primes, Reading from Files and Printing to

Files2

Page 3: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

SWIInstructions Plug-in Overview Implements Software Interrupt Codes to allow

for common I/O operations

Included in ARMSim# 1.91 Download

Enabled/Disabled via File->Preferences->Plugins->SWIInstructions

Enabled by Default

3

Page 4: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Types of I/O Operations Open/close files

Write characters and strings to Stdout or file

Reading from files and Stdin (Keyboard)

Allocate/deallocate memory on Heap

Interact with other Plug-ins (ex. Embest Board)

4

Page 5: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

SWI Codes

5

Page 6: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

SWI Codes

6

SWIcodes from 0 to 255 are forArmSim# I/O, codes above 255 are used for interaction with other ArmSim# plugin modules

Page 7: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

How SWI Works Not really an exception or a proper interrupt

Enables the user to call routines in supervisor mode

Most ARM systems have a well-defined set of operations accessible through SWI

7

Page 8: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Outline Overview of SWIInstructions Plug-in for

ArmSim# Basic SWI Operations for I/O Stdin/Stdout/Stderr View ArmSim# I/O Examples with SWI

Printing Characters Printing Strings Determining Primes, Reading from Files and Printing to

Files8

Page 9: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Stdin/Stdout/Stderr View Where output from user programs is

displayed

Stdout: Output to file, pipe, or console

Stderr: Output stream for errors

Requests from Stdin freeze ARMSim# until input is received

Input is echoed in Stdin/Stdout/Stderr View9

Page 10: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Stdin/Stdout/Stderr View

10

Page 11: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Example 1 – Printing Characters .equ [symbol], [swi code] makes

code more readable

swi 0x00: Display character stored in R0 to Stdout

swi 0x11: Halt execution

#’[char] uses ASCII value for character like an immediate value

11

Page 12: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Example 2 – Printing Strings swi 0x02: Displays an ASCII

string to Stdout (Address in R0)

String must be null-terminated (.asciz)

ASCII for “Hello World!\n” = 48,65,6C,6C,6F,20,57,6F,72,6C,64,21,0A,00

Little-endian byte address assignment

12

Page 13: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Outline Overview of SWIInstructions Plug-in for

ArmSim# Basic SWI Operations for I/O Stdin/Stdout/Stderr View ArmSim# I/O Examples with SWI

Printing Characters Printing Strings Determining Primes, Reading from Files and Printing

to Files13

Page 14: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

Example 3 – Is Prime

14

Page 15: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

QUESTIONS?

15

Page 16: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

References http://armsim.cs.uvic.ca/index.html

ARMSim_UserGuide4Plus.pdf

ARM system-on-chip architecture, second edition, Steve Furber, Addison Wesley, 2000      

16

Page 17: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

BACK-UP SLIDES

17

Page 18: 1 ARMSim# and SWIInstructions Plug-in Group 11: Brian Knight Benjamin Moore Alex Williams

SWI Instructions step by step SVC mode is entered R15 is saved to R14_SVC The IRQ disable bit is set The PC is set to address &00000008, this

address has the instruction which jumps to the real SWI handler

18