ECE 4436 Microprocessor Systems - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

ECE 4436 Microprocessor Systems

Description:

ECE 4436. Microprocessor Systems. Monday: February 12, 2001. Week ... BLT ( ) BLTU. BLE ( =) BLEU. BGT ( ) BGTU. BGE ( =) BGEU. Ex. is 11112 greater than 00002? ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 19
Provided by: DianaDe1
Category:

less

Transcript and Presenter's Notes

Title: ECE 4436 Microprocessor Systems


1
ECE 4436Microprocessor Systems
  • Monday February 12, 2001
  • Week 05 Lecture 08

2
Todays Agenda
  • Annoucements/News
  • HW4
  • Midterm ? Wednesday, February 28th!
  • SPIM demo
  • Assign Lab 1
  • C Declarations Copies
  • Flow Control Instructions
  • For While Loops Using Arrays
  • Handout on Loops

3
C Declarations Copies
  • char a 0xAB
  • char b 0
  • unsigned char c 0xA0
  • short int d 0xABCD
  • short int e 0
  • unsigned short int f 0xABC0
  • int g 0x89ABCDEF
  • int h 0
  • unsinged int i 0x89ABCDE0
  • a _____ 0xAB
  • b _____ 0
  • c _____ 0xA0
  • d _____ 0xABCD
  • e _____ 0
  • f _____ 0xABC0
  • g _____ 0x89ABCDEF
  • h _____ 0
  • i _____ 0x89ABCDE0

4
C Declarations Copies
5
C Declarations Copies
  • b a
  • LB t0,a char ? char
  • SB t0,b
  • h f
  • LHU t0,f int ? unsigned short int
  • SW t0,h
  • h g
  • LW t0,g int ? int
  • SW t0,h

6
C Declarations Copies
  • i 0xABCD
  • LI t0,0xABCD
  • SW t0,i
  • g i
  • LW t0,i overflow error if i ? 0x80000000
  • SW t0,g int ? int unsigned
  • e a
  • LB t0,a short int ? char
  • SH t0,e
  • b f
  • LHU t0,f overflow error
  • SB t0,b if f ? 0x80

7
Flow Control Instructions
  • Unconditional transfer of control.
  • Conditional transfer of control.
  • A label in used to indicate the target of a
    branch, jump or subroutine call.

8
Unconditional Branch
  • J label
  • transfer control unconditionally to instruction
    following label
  • Ex.

loop add t1,s3,s3 sw t1,8(s4) j loop
9
Conditional Branches
  • BEQ R1,R2,label
  • compare R1 and R2. If , transfer control to
    label. If ? execute next instruction.
  • Ex. BEQ t1,t2,exit
  • BNE R1,R2,label
  • take branch if R1 ? R2
  • Ex. BNE t1,t2,loop

10
Conditional Branches
  • 10 Conditional Branches
  • BEQ () BNE (!)
  • BLT (lt) BLTU
  • BLE (lt) BLEU
  • BGT (gt) BGTU
  • BGE (gt) BGEU
  • Ex.
  • is 11112 greater than 00002?

11
Conditional Branches
  • Also have some pseudoinstructions
  • BEQZ BLTZ BGTZ
  • BNEZ BLEZ BGEZ
  • Ex
  • BEQZ t0,label7 take branch if t00

12
Conditional Branches
  • Ex 1
  • Ex 2

13
Conditional Branches
  • Ex 3

if (ij) ff-i else fgh
14
Branch Formats
  • Jump is a J-type instruction
  • Conditional Branches are I-type instructions

op
target addr. / 4
15
For While Loops Using Arrays
  • Ex. clear an uninitialized array
  • int arrayA100
  • for (i0 ilt100 i) arrayAi 0
  • Let
  • i s3
  • base addr. of A s4
  • 100 t1

16
For While Loops Using Arrays
.data arrayA .space 400 .text LI t1,100
load count MOVE s3,zero i
0 LA s4,arrayA load addr. of
A LOOP BGE s3,t1,DONE done? ADD t2,s3,s3
i ? 2 i ADD t2,t2,t2 double
again ADD t2,t2,s4 ArrayAi SW zero,0(t
2) ArrayAi ADD s3,s3,1
i J LOOP DONE
17
See Handout on For While Loops!
18
Assignment for Wednesday
  • Check web for slides
  • Study for Quiz on Wednesday!
  • Play with SPIM
  • Start Lab 1!
  • Read PH 3.5, handout

19
Scratch Pad
Write a Comment
User Comments (0)
About PowerShow.com