CS255 Syllabus

### Important property of computer (= machine) instructions

• Very important property of computer (machine) instructions of a computer

• Very important fact:

• The CPU can only perform operations on 2 values of the same data type with each other

In other words:

 The CPU can add 2 byte values     or       The CPU can add 2 short (2 bytes) values,     or       The CPU can add 2 int (2 bytes) values,     or       The CPU can add 2 float (4 bytes) values,     or       The CPU can add 2 double (8 bytes) values And so on !!!! The CPU can subtract 2 byte values     or       The CPU can subtract 2 short (2 bytes) values,     or       The CPU can subtract 2 int (2 bytes) values,     or       The CPU can subtract 2 float (4 bytes) values,     or       The CPU can subtract 2 double (8 bytes) values And so on !!!! Etc. etc....

• Therefore:

• When the CPU needs to perform an operation on values of different data types:

 The CPU must (use a machine instruction to) convert the different types to a common (= same) data type Then perform the desired operation on 2 values of the same type !!!

• Order of presentation on material on operations using different data types

• Presentation:

1. We will first learn how the computer operate on data/values of the same (data) type

 We will study arithmetic operations using the same data type

2. Next, we study how the computer operate on data/values of the different (data) types:

 How the computer store values of a different type How the computer performs computations on values of a different type

(You will see that the computer must perform conversions first !!!)

• Teaching this material in M68000...

• Unfortunate "distraction" in M68000:

• The M68000 can perform the add operation in a data register or in an address register

Example:

 ``` add.l #3, D0 // Add 3 to the value in register D0 adda.l #3, A0 // Add 3 to the value in register A0 ```

• The behavior of the operation is slightly different when you use an address registers

It's unfortunate because ideally:

 the behaviour of each operation should be the same (so you don't need to remember additional rules when you write a M68000 program