05.08.2014 Views

Lecture Notes for Computer Architecture II - St. Cloud State University

Lecture Notes for Computer Architecture II - St. Cloud State University

Lecture Notes for Computer Architecture II - St. Cloud State University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

High Level Language <strong>St</strong>atements Assembly Language Translation<br />

HLL MIPS Assembly<br />

MIPS Machine<br />

In general the translation process includes<br />

1. assigning variables in high level language statement into registers<br />

2. Translation into assembly<br />

Page | 37<br />

Simple arithmetic instructions - manipulate data in registers<br />

Problem<br />

Translate the a = b + c; High Level Language (HLL) statement into assembly language<br />

Solution<br />

compiler<br />

1. a = b + c add a,b,c<br />

Problem<br />

Translate HLL statement A = b+c+d+e; to AL<br />

Solution<br />

add a,b,c<br />

add a,a,d<br />

add a,a,e<br />

Problem<br />

HLL d = a-e;<br />

compiler<br />

d = a-e sub d, a, e<br />

Problem<br />

Translate HLL f = (g+h) – (i+j) into MIPS assembly language<br />

Solution<br />

<strong>St</strong>ep1 Assign variables to registers<br />

f g h i j<br />

<br />

$S 0 $S 1 $S 2 $S 3 $S 4<br />

<strong>St</strong>ep 2 Do simple translations<br />

add t 0 , $S1, $S2<br />

add t 1 , $S3, $S4<br />

sub $S0, t 0 , t 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!