20.02.2013 Views

An Introduction to a Simple Computer - Jones & Bartlett Learning

An Introduction to a Simple Computer - Jones & Bartlett Learning

An Introduction to a Simple Computer - Jones & Bartlett Learning

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

00068_CH04_Null.qxd 10/18/10 12:03 PM Page 230<br />

230 Chapter 4 / MARIE: <strong>An</strong> <strong>Introduction</strong> <strong>to</strong> a <strong>Simple</strong> <strong>Computer</strong><br />

in<strong>to</strong> the accumula<strong>to</strong>r. This saves the machine cycles that would otherwise be<br />

expended in loading a 0 operand from memory.<br />

With the AddI, JumpI, LoadI, and S<strong>to</strong>reI instructions we introduce a different<br />

addressing mode. All previous instructions assume the value in the data portion<br />

of the instruction is the direct address of the operand required for the<br />

instruction. These instructions use the indirect addressing mode. Instead of using<br />

the value found at location X as the actual address, we use the value found in X as<br />

a pointer <strong>to</strong> a new memory location that contains the data we wish <strong>to</strong> use in the<br />

instruction. For example, <strong>to</strong> execute the instruction AddI 400, we first go <strong>to</strong> location<br />

400. If we find the value 240 s<strong>to</strong>red at location 400, we would go <strong>to</strong> location<br />

240 <strong>to</strong> get the actual operand for the instruction. We have essentially allowed for<br />

pointers in our language, giving us tremendous power <strong>to</strong> create advanced data<br />

structures and manipulate strings. (We delve more deeply in<strong>to</strong> addressing modes<br />

in Chapter 5)<br />

Our six new instructions are detailed below using register transfer notation.<br />

JnS LoadI X<br />

MBR ← PC MBR ← X<br />

MAR ← X MBR ← M[MAR]<br />

M[MAR] ← MBR MAR ← MBR<br />

MBR ← X MBR ← M[MAR]<br />

AC ← 1 AC ← MBR<br />

AC ← AC + MBR<br />

PC ← AC<br />

S<strong>to</strong>reI X<br />

Clear MBR ← X<br />

AC ← 0 MBR ← M[MAR]<br />

AddI X<br />

MAR ← X<br />

MBR ← M[MAR]<br />

MAR ← MBR<br />

MBR ← M[MAR]<br />

AC ← AC + MBR<br />

JumpI X<br />

MAR ← X<br />

MBR ← M[MAR]<br />

PC ← MBR<br />

MAR ← MBR<br />

MBR ← AC<br />

M[MAR] ← MBR<br />

Table 4.7 summarizes MARIE’s entire instruction set.<br />

Let’s look at some examples using the full instruction set.

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

Saved successfully!

Ooh no, something went wrong!