Beruflich Dokumente
Kultur Dokumente
COMP 229 (Section PP, Winter 2006) Week 1 Prof. Richard Zanibbi Concordia University January 9, 2006
System Software
A set of tools designed to simplify programming for a specific machine (or hardware system) Concerned with using hardware efficiently Used to construct and run Application Software
Object Program
Produced from a source program by compiling/assembling to intermediate machine code Intermediate machine code augmented by:
References (possibly undefined) Additional instructions related to combining the object program with other object programs, and/or executing the object program
Link / Load
Executable Program
Instruction sequence that a computer can directly execute (machine code)
May be produced directly by a compiler/assembler Often produced by combining object programs
Assembler
Translates assembly language programs to object programs or machine code
Linker
Combines and resolves references between object programs
Loader
Loads an executable program and starts its execution
(Low-level) Debugger
Used to debug executable programs and their associated object and source programs (trace variables, set breakpoints, etc.)
Math L.
Machine Architecture for the Simplified Instructional Computer (SIC) and the Extended SIC/XE
SIC Architecture
CPU
Ready ? ?
1111 1111
Memory Address(Hex)
. . .
Value (Binary)
. . .
(8)PC (9)SW
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Ready ? ?
1111 1111
Memory Address(Hex)
. . .
Value (Binary)
. . .
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
Memory
Memory contains 8-bit bytes; all addresses are byte addresses 3 consecutive bytes form a word (24 bits: this is also the SIC instruction size) Words accessed by location of first byte in the word (by lowest numbered byte) SIC: 215 bytes in memory (32,768) (32 k), addressed as 0 through 32,767 SIC/XE: 1 megabyte of memory (220 bytes)
Characters
8-bit ASCII codes
s: sign (0: +ve or 0, 1: -ve) exponent: unsigned binary number fraction: decimal point before first bit (1 for normalized values) |floating point number| = f * 2(e-1024)
Registers
Register Purpose of Register (*each is 24 bits, except F)
(0) A Accumulator: arithmetic, I/O (1) X Index: addressing (2) L Linkage: storing return addresses for subroutines
(e.g. for JSUB)
SIC/XE only
(3) B Base: addressing (4) S General working register (5) T General working register (6) F Floating Point Accumulator (48 bits) (8)PC Program Counter: address of the next instruction
to be fetched for execution
Input Example
CPU
Ready ? ?
1111 1111
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
Input Example
Device 0 Ready? CPU (TD 0)
Ready ? ?
1111 1111
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
Input Example
Yes CPU
Ready
Y
?
1111 1111
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
<
Input Example
Read Device 0 CPU (RD 0)
Ready
Y
?
1111 1111
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
<
Input Example
0010 1111 CPU
Ready
?
?
1111 1111
(0) A 0000 0000 0000 (1) X (2) L (3) B (4) S (5) T (6) F (8)PC (9)SW
<
Upward compatability: SIC instructions may be represented using SIC/XE Format 3 (n,i bit flags set to zero)
n i xbpe
Addressing Types: Computing the Target Address Value Relative: TA computed using register B (base-relative) or register PC (program-counter relative)
Base-relative: displacement field interpreted as unsigned int PC-relative: displacement interpreted as 2s complement signed integer
Direct: target address computed without the use of B or PC Indexed: TA computed using the index register (X) (can be used with relative or direct addressing)
Addressing Types: Use of Data at Target Address Simple: target address contains operand Indirect: target address contains address of the operand Immediate: target address is the operand (no lookup)
i
SIC
x b p e
SIC Addressing
Only direct and simple addressing, with an optional indexed mode (the x bit) is available on a plain SIC machine
8 bits opcode x address 15 bits
Indexed: x =1
SIC
n,i = 1,0
n,i = 0,1
Note: Cannot use indexing with Indirect, Immediate Modes Note2: Cannot use b or p relative addressing with Format 4 (e bit): direct addressing only
Addressing Examples
Study the different addressing mode examples in Figure 1.1 (page 11)
Look at the example SIC and SIC/XE programs on pages 12-20 in the textbook
SIC Architecture
CPU
Ready ? ?
1111 1111
Memory Address(Hex)
. . .
Value (Binary)
. . .
(8)PC (9)SW
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Assembler Directives
Assembly commands that are not machine instructions (pseudo-instructions) Used to generate numeric and character constants, reserve data space (e.g. for variables) Directives also used to indicate the start and ending address of a program
Main Loop
Pass 2
Performs most of the translation to object code, making use of label addresses assigned in Pass 1
Comments
Comment (omitted) . . .
Error
CAT
DOG CLOOP
INVALID-OPCODE DUPLICATE-SYMBOL
. . .
Example: Intermediate File with Errors After Pass 1 (Altered Fig. 2.2)
Comment (omitted) . . .
Obj. Code/Error
CAT
DOG CLOOP
281030
. . .
Example: Error in Assembly Listing File After Pass 2 (Altered Fig. 2.2)
Object Code Format for SIC Assembler Output Cols Contents 1 H 2-7 Program name 8-13 (Hex) Starting address of object program 14-19 (Hex) Length of object program in bytes 1 T (Hex) Starting address for object code in the record 8-9 (Hex) Length of object code in bytes 10-69 (Hex) Object Code: 2 cols per byte 1 E 2-7 (Hex) Address of first executable instruction 2-7
Header Text
End
Program Name Addresses (Program start, Object code segment start) Lengths (Program length, Text Record Length) Object Code
Opcode Handling
Assembler Directives
Assembler Directives