1 of 10

TOY Programming

Find a partner or group; discuss:

  1. Remind me, which of the 4 digits in a TOY instruction is called the op code?
  2. How many registers does a TOY machine have? Also, how many memory locations?
  3. Why do we have both registers and memory? What are registers typically used for? How about memory?

2 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

3 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

First digit. The op code tells you which of the 16 operations a given instruction is executing.

4 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

5 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

There are 16 of these, numbered 0 through F.

6 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

There are 256 of these, numbered 00 through FF.

There are 16 of these, numbered 0 through F.

7 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

8 of 10

TOY Programming

Find a partner or group; discuss:

  • Remind me, which of the 4 digits in a TOY instruction is called the op code?
  • How many registers does a TOY machine have? Also, how many memory locations?
  • Why do we have both registers and memory? What are registers typically used for? How about memory?

We use registers to store intermediate values; we use memory to store longer-term data.

9 of 10

TOY Programming

ALU

_ _

_ _ _ _

0 0 0 0

0

_ _ _ _

1

_ _ _ _

F

_ _ _ _

STDIN & STDOUT

IR

16 bits

REGISTERS

MEMORY

_ _ _ _

00

_ _ _ _

01

_ _ _ _

_ _ _ _

0F

_ _ _ _

10

_ _ _ _

11

_ _ _ _

_ _ _ _

1F

_ _ _ _

F0

_ _ _ _

F1

_ _ _ _

_ _ _ _

FF

2

F2

12

02

PC

8 bits

load

store

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

. . .

8 bit

memory

address

16 bit

memory

word

16 bit

register

10 of 10

Ready to dive in?

No code today either! Let's review the 16 operations in TOY and write our first few TOY programs!

No need for laptops today, unless you want to take notes on your computer.