Ami Pro - HW01.SAM

ECE 376 - Homework #1
Boolean Math, Computer Architecture - Due Monday, August 31st
1) Boolean Math: Assume 8-bit unsigned integers for all data (meaning all answers are in the range of
0..255). Find the result of the following operations:
Binary
Hexadecimal
Decimal
87 + 176
0101 0111
+ 1011 0000
---------------1 0000 0111
0x57
+ 0xB0
---------0x107
7
87 - 176
0101 0111
- 1011 0000
---------------1 1010 0111
0x57
- 0xB0
-----------0xFFA7
+ 167
(-89)
87 * 176
0101 0111
* 1011 0000
---------------0011 1011 1101 0000
0x57
* 0xB0
-----------0x3BD0
87 AND 176
0101 0111
AND 1011 0000
---------------0001 0000
0x57
& 0xB0
-----------0x10
16
87 OR 176
0101 0111
OR 1011 0000
---------------1111 0111
0x57
| 0xB0
-----------0xF7
247
87 XOR 176
0101 0111
+ 1011 0000
---------------1110 0111
0x57
^ 0xB0
-----------0xD7
231
+208
= 15312 mod 256
2) Assume a processor with a Harvard architecture has the following memory:
Flash ROM: 32k x 16
RAM
4k x 8
Stack
32 x 15
2a) What type of processor is this? (4-bit, 8-bit, 16-bit, 32-bit). 8-bit
The RAM tells you tyhe type of processor; When you add, subtract, etc. you're operating on
8-bits of data. This is an 8-bit processor.
2a) How many lines of assembler can a program be? 32k
ROM is where program memory is stored. You can store 32k instructions in assembler.
2b) How many integers can you store in memory? 2000
Each integer takes two bytes. You can store 4k bytes in RAM. Divided by 2 gives 2k.
2c) What is the largest NxN matrix of double precision floating point numbers can you store? 22 x 22
Each double precision float takes 8 bytes. With 4k RAM, you can store 500 double precision
numbers. Taking the square root, you get 22.36, or 22
2d) How many levels of subroutine calls can you make? (i.e. a subroutine calls a subroutine which calls
another subroutine, etc.) 32
The stack tells you how many nested subroutine calls you can make. A subroutine can call a
subroutine, which calls another subroutine (etc) up to 32-levels deep.
3) Assume an 8-bit processor with a Von Neumann architecture has the following memory:
RAM:
64k x 8
3a) How many lines of assembler can a program be? <= 64k
You don't really know - it depends upon the program. Some assembler instructions take several
bytes. The simplest just take one.
Note: This answer assumes you have no memory and no stack.
3b) How many integers can you store in memory? <= 32k
Assuming there is no program memory and no stack (all data), you can store 32k integers.
Less if you have a program and a stack.
3c) What happens if you write to address 1000 for an integer DATA[10]? You overwrite something
else
The C-compiler should give you an 'out of range error'. If not, it just writes to whatever spot in
memeory is DATA offset by 2000. This might be your program, another variable, or the stack.
Usually this results in a program which crashes (quits running). This is also a really difficult
error to detect and debug.
BONUS! Due to relativistic effects, time runs slower at the equator. How long would two identical
clocks have to run, one at the equator, one at the North Pole, until the one at the equator loses 100ns due
to relativistic effects? (note: 100ns is one clock with the PIC processor we're using).
From Wikipedia on time dilation
The Lorentz factor is

2
1
1
v2
 1  12 vc 2
c2
The diameter of the earth is 12,756 km. Rotating once per day meanss clocks at teh equator are moving
v
d
24h
 463.8 ms
The Lorentz factor is then
  1  1.06e  12
Time at the equator runs slower at the equator by one part in 1012 or -104ns every 24h,
BUT, gravity is also less at the equator due to centrifugal force by about 0.5%. Strong gravitational fields
slow down time, weaker fields speed up time. This results in time at the equator speeding up by
+108ns/24h.
Combining the two, time runs a little fast at the equator: about +4ns/24h. It would take 25 days to shift
100ns.
Source: http://www.alternativephysics.org/book/GRexperiments.htm