# 1. Bits, Data Types, and Operations¶

For today's class, we will work in small groups (two or three). One of you, open a blank notebook, and the others should close their laptops. We will trade-off typing as we go.

## 1.1 Representing Signed Integers¶

Three representations of signed integers: Q1: What is unusual about two of the columns? There is a number there that you don't usually see.

## 1.2 Signed Magnitude¶

Q2: What is 11111 + 01111 ?

## 1.3 One's Complement¶

Q3: What is 10000 + 01111 ?

## 1.4 Two's Complement¶

Q4: Work out by hand: What is 10001 + 01111 ?

Q5: Work out by hand: What is the two's complement for -13?

Q6: Work out by hand: What is the two's complement for -57 ?

Q7: Using the LC-3, compute the following:

• a: 8 + -7
• b: 5 + 5
• c: -5 + -5
• d: -15 + 15
• e: -8 + 1
• f: -15 + -1
• g: -16 + -1

## 1.5 Binary to Decimal Conversion¶

NOTE: All binary will be in two's complement.

Q8: Work out by hand: convert 01000 to decimal

Q9: Work out by hand: convert 11000 to decimal

Q10: Work out by hand: convert 11111 to decimal

Q11: Work out by hand: convert 111111111 to decimal

Q12: Work out by hand: convert 000001000 to decimal

## 1.6 Decimal to Binary Conversion¶

Q13: Convert decimal 105 to binary

Q14: Convert decimal -105 to binary

Q15: convert decimal 99 to binary

Q16: convert decimal -14 to binary

Explore the patterns of adding any two numbers to itself. Try positive and negative numbers.

Q17: Do you see a pattern? Describe it.

# 2. Logical Operations¶

Two new instructions:

Bitwise AND and NOT (16 bits each):

AND: 0101 DST SRC 1 VVVVV
NOT: 1001 DST SRC 111111

where:

• DST - destination register, in three bits
• SRC - source register, in three bits
• VVVVV - value to AND with source register contents

Q18: Write out the truth tables for AND and NOT.

Q19: Write out the truth tables for OR and XOR

Q20: Try out the AND and NOT instructions on the LC-3. Do they work as described?