Title: Basics Instruction Set Architecture
1BasicsInstruction Set Architecture
- Panickos Neophytou
- Recitation 1 09/07/2005
- 09/12/2005
CS0447 Computer Organization and Assembly Link
for this presentation www.cs.pitt.edu/panickos/c
lasses/cs0447/Basics.ppt
2Contact info
- Panickos Neophytou
- Office
- 6514 Sennott Square
- Office Hours Monday 230-530 Tuesday
345-645 - Email
- panickos_at_cs.pitt.edu (use cs0447 anywhere in
the subject to get my attention) - TAs course web page
- www.cs.pitt.edu/panickos/classes/cs0447 (under
construction BUT available)
3Outline
- Decimal to Binary conversions
- Binary to Hexadecimal conversions
- Instruction Set Architecture
- SPIM
4Decimal to Binary conversions
          Â
- Example 1 - (Convert Decimal 44 to Binary)
5Decimal to Binary conversions
- Example 2 - (Convert Decimal 15 to Binary)
6Decimal to Binary conversions
                          Â
- Example 3 - (Convert Decimal 62 to Binary)
7Binary to Hexadecimal conversions
- In the Hexadecimal system you have 16 symbols to
represent natural numbers.
8Binary to Hexadecimal conversions
- Convert the following Hex number to Binary
- 286F A3E1
- Convert the following Binary number to
Hexadecimal - 0101 0011 1111 0110 1011 1010 0001 1100
9Instruction Set Architecture
- op Operation code Â
- rs First source register operand Â
- rt Second source register operand Â
- rd Destination register operand Â
- shamt Shift amount - used in shift instructions Â
- funct Select the variant of the operation in the
op code field
10Instruction Set Architecture
- Specific Instruction Formats
11Instruction Set Architecture
12Instruction Set Architecture
13Instruction Set Architecture
14Instruction Set Architecture
15Instruction Set Architecture
16SPIM
- Spim is a self-contained simulator that will run
MIPS32 assembly language programs. - Freeware
- Can be downloaded and installed onto Windows or
Unix based machines from - http//www.cs.wisc.edu/larus/spim.html
- Will be used for assignments
17SPIM
- Registers
- Instructions
- Loaded Data
- Output
18SPIM - Assembler Syntax
- Program includes .data and .text
- Comments begin with . Rest of line is ignored.
- Identifier names are sequence of letters,
numbers, underbars (_) and dots (.). - Labels are declared by putting them at beginning
of line followed by colon. Use labels for
variables and code locations. - Instruction format op field followed by one or
more operands addi t0, t0, 1 - Operands may be literal values or registers.
- Register is hardware primitive, can stored 32-bit
value s0 - Numbers are base 10 by default. 0x prefix
indicates hexadecimal. - Strings are enclosed in quotes. May include
\nnewline or \ttab. Used for prompts.
19SPIM
SPIM Code to print hello world a comment
starts with a till the end of the lineÂ
.data start putting stuff in the data
segment greet .asciiz Hello world\n declare
greet to be the string .text start
putting stuff in the text segment main main
is a label here. Names a function li v0, 4
system call code for print_str la a0, greet
address of string to print syscall print the
string jr ra return from main here li
is load immediate into an integer register la
is load computed address into an integer
register jr is standard return from function
call...ra contains return address
20SPIM
- Modify the program by adding these instructions
- addi 10, 10, 4
- addi 11, 11, 28
- add 12, 10, 11
- Use the step option (from the Simulator menu)
of SPIM to watch your programs execution
step-by-step.
21MIPS Basics
- Implementing Conditional Statements
if ( i j ) i j--
bne r1, r2, L1 branch if ! ( i j )
addi r1, r1, 1 i L1 addi r2, r2,
-1 j--
if ( i j ) i else j-- j i
bne r1, r2, ELSE branch if !( i j )
addi r1, r1, 1 i j L1 jump
over else ELSE addi r2, r2, -1 j
L1 add r2, r2, r1 j i