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.

Download Report

Transcript 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.

ARMSim# and
SWIInstructions Plug-in
Group 11:
Brian Knight
Benjamin Moore
Alex Williams
1
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
Files
2
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
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
SWI Codes
5
SWI Codes

SWIcodes from 0 to 255 are forArmSim# I/O,
codes above 255 are used for interaction with
other ArmSim# plugin modules
6
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
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
Files
8
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 View
9
Stdin/Stdout/Stderr View
10
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
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
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 Files
13
Example 3 – Is Prime
14
QUESTIONS?
15
References

http://armsim.cs.uvic.ca/index.html

ARMSim_UserGuide4Plus.pdf

ARM system-on-chip architecture, second edition,
Steve Furber, Addison Wesley, 2000
16
BACK-UP SLIDES
17
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