Brookshear MIT
Brookshear MIT
Programming
Prof. I. K. Lundqvist
Recitation 2
Sept 18 2003
Some suggestions …
C5, C6, C7
• Binary, Decimal, Hex, ASCII
• Negative numbers / 2’s complement
• Floating point numbers
– Excess
• The Brookshear Machine
– The Brookshear Instruction Format
– Brookshear Machine Instructions
• Bit-wise Logical Operations
– Masking
• The Simple Simulator
• SimpleSim examples
– Add three numbers together
– Converting lowercase characters to uppercase
Assembly programs
BACK
1001001 11001001
and 1100111 or 01100111
1000001 11001111
100101101
xor 110010011 Masking: to test
010111110 the individual
pattern of bits in a
string of bits
Masking: Reading
• Example: Determine if a number is odd or even.
Masking: Setting
Masking: Exercises
1. What mask and operator is needed to convert lower case ASCII
character to uppercase character? E.g., ‘u’ should be changed to
‘U’, ‘n’ to ‘N’ and so on…
Hint: take a look at the ASCII values for characters represented
in binary notation [ASCII for ‘a’ = 0110 0001, ASCII for ‘A’ =
0100 0001, etc. ]
2. Given two bytes. Create a third byte that combines the first
half of the 1st byte (4 bits) with the last half of the 2nd byte (4
bits).
– For example, given 01101001 and 11100111, the answer
would be 01100111.
What sequence of logical operations using bit masks are needed
to do this?
BACK
Excess Notation
With N bits representation of the exponent we have
excess 2N-1
3 bits => excess 4 (=23-1)
Value
4 bits => excess 8 (=24-1)
Bit Pattern 8 bits => excess 128 (=28-1)
Represented
1111 7 Value
1110 6 Bit Pattern
Represented
1101 5
1100 4
111 3
1011 3
1010 2 110 2
1001 1
1000 0 101 1
0111 -1 100 0
0110 -2
0101 -3 011 -1
0100 -4
0011 -5 010 -2
0010 -6 001 -3
0001 -7
0000 -8 000 -4
ASCII
C 0100 0011 c 0110 0011
D 0100 0100 d 0110 0100
E 0100 0101 e 0110 0101
F 0100 0110 f 0110 0110
G 0100 0111 g 0110 0111
H 0100 1000 h 0110 1000
I 0100 1001 i 0110 1001
J 0100 1010 j 0110 1010
K 0100 1011 k 0110 1011
L 0100 1100 l 0110 1100
M 0100 1101 m 0110 1101
N 0100 1110 n 0110 1110
O 0100 1111 o 0110 1111
P 0101 0000 p 0111 0000
Q 0101 0001 q 0111 0001
R 0101 0010 r 0111 0010
S 0101 0011 s 0111 0011
T 0101 0100 t 0111 0100
U 0101 0101 u 0111 0101
V 0101 0110 v 0111 0110
W 0101 0111 w 0111 0111
X 0101 1000 x 0111 1000
Y 0101 1001 y 0111 1001
Z 0101 1010 z 0111 1010 BACK