Midterm 1 Flashcards
What are the main components of a computer?
Memory: Main memory or RAM (volatile), secondary memory (non-volatile- examples are like flash memory and discs), cache memory (also volatile)
Processor (CPU): Arithmetic/logic circuits, timing/control circuits, registers, and cache memory
Input: keyboard, mouse, touchpad, cameras
Output units: printers, speakers
How do the different components of the computer communicate with one other.
Each component of a computer (memory, processor, input, and output) are connected through an interconnected network. A component that is missing could be internet connection if a computer wanted to access data from the internet
What is the smallest unit of memory?
A bit (or a binary digit)
A bit may be either a ________ or a _________
0, 1
What are the hardware devices that can store a bit called?
Also called bits
When you are writing a bit, you are overwriting it. Explain what this means.
When you overwrite a bit, it means the original bit that you have written, isn’t going to be there anymore. Meaning if you wrote a 1 before, and you write a 0 now, the new value of the bit is 0 and the 1 disappears.
True or False: The main memory of a computer system is where data information is kept.
True
Data can be many different types. Provide some examples:
Audio, visual, integer, character, float, etc.
Before you run a program (any program) where is it?
It will be located on the hard drive or disc
In order for any instruction of a program to execute, where does the instruction have to be? Where does the data for that instruction have to be?
In order for any instruction of a program to execute, the instruction as well as the data for that instruction should be in the computer’s memory.
Main memory is also referred to as what?
Random Access Memory or RAM
What happens when you shut down a machine? Explains what happens with the memory.
When you shut down a machine, due to memory technology, contents in the main memory disappear. We require power for certain machines, so not having the appropriate technology or power for your machine could result in the contents of the main memory disappearing
True or False: Processor gets information from input and output devices
True
To prevent overwriting and to retain the old bit, what must we do?
We must store the bit string as a new variable
What is an ordered sequence of 1 or more bits called?
A bit string
True or False: “10” and “01” are different bits strings.
True. It does NOT matter if the bit strings comprise of the same bits, the order matters. If they are in a different order, they are different bit strings
How do we store EVERYTHING as a bit string?
By encoding everything as a bit string. Encoding mean converting the meaning/value to a bit string that can be used to represent it
If given the bit string “01” and if you are asked what it represents, (not the value of a bit string) what should your answer be?
No idea. It is impossible to tell as it could have various meanings. More context must be provided
True or False: Memory is organize into a sequence or an array of words.
True
In the prior generation of hardware, a word was a string of 32 bits. How many bits is a word in this generation?
64 bits. However, there is no universal agreement on the definition or size of a word. Unless and otherwise stated, we will assume it is 64 bits.
A byte is ALWAYS defined as what?
A string of 8 bits. A byte is ALWAYS a string of 8 bits. This definition is universal
In this generation, a word would be how many bytes?
A word would be 8 bytes in this generation.
For unsigned binary numbers, how do we find the largest number that can be encoded for n number bits?
2^n-1
What is the smallest number that could be encoded for a bit string?
0
What is the range of values which can be encoded by B2U number of n bits?
0 through 2^n-1
True or False: The range is dependent on n number of bits. Larger n, bigger range.
True
How do we encode values using B2U?
You start by using the rightmost digit and you multiply that with 2*0. Your leftmost digit should be multiplied by 2^n-1.
Example: The bit string “11001” denotes the value of 25. How?
1 *2^0 + 0 *2^1 + 0 *2^2 + 1 *2^3 + 1 *2^4 = 1+0+0+8+16= 25
What is the encoding scheme for negative numbers called and how does it work?
Binary to sign and magnitude (B2S). A first bit of 0 is used to denote for a non-negative number and 1 for negative number so “0101” denotes +5 and “1101” denotes -5.
True or False: B2S is extremely efficient in machines.
False. B2S is intuitive and does NOT work well in machines, and nobody uses it for signed numbers.
Using B2U, compute the arithmetic operation of adding the following two 4 bit numbers “0101” and “0110”
Carry: 0 1000
1st Number: 0101
2nd Number: 0110
Sum: 1011
What is the lsbs?
Least significant bits; the rightmost pair of bits
What is overflow?
Overflow means that the sum generated by the addition hardware is NOT ACCURATE because there are not enough bits to store the accurate/correct result.
Show an example of overflow using B2U and explain the issue:
Carry: 1 1100
1st number: 0110
2nd number: 1010
Sum: 0000
Here, the sum is 0 when in reality it should be 16 as the 1st bit string adds up to 6 and the 2nd bit string adds up to 10. However, there is overflow which resulted in the incorrect sum. This is due to the fact that the largest value encoded in a bit string comprised of 4 bits is 15. The result of 16 is too big.
Why can we just not add another bit to counter overflow? Meaning, if the processor is adding two 4 bit numbers, and the there is overflow (the anticipated result doesn’t fit in 4 bits) why don’t we just add an extra bit to store the result? In other words, why don’t we store it as a 5 bit result?
This is not effective as this makes the hardware way more complicated and the performance will not be any better than if you were to store it as a 4 (or however many) bit result. This is exactly why no manufacturer builds a computer that uses an extra bit to store the proper result when there is overflow.
True or False: Because adding an extra bit to store a result when there is overflow is inefficient, CPUs generally use the same number of bits to store results that are used for operands. CPUs generally only work on operands of certain number of bits (8, 16, 32, and 64 bit operands/results are what all general-purpose CPUs have today)
True
All CPUs store the carry from the addition of the msbs somewhere, so that overflow can be detected. Processors store this last carry in a 2 1 bit flag. What is this called and what is its abbreviation?
This called the carry flag, and its abbreviation is C.
For an unsigned arithmetic operation, what does it mean when C is 1?
This means that the result derived from the last arithmetic operation is incorrect
For an unsigned arithmetic operation, what does it mean if C is 0?
The result of the last arithmetic operation is correct.
What is the msbs?
Most significant bits; this is the leftmost bit in a bit string
For the 2’s complement, what are our 3 priorities?
- Want to have roughly equal number of positive and negative number (suppose we have 3 bits, meaning total of 8 different bit strings, ideally we would like to have 4 positive and 4 negative numbers)
- We want to have as many numbers as possible (that is, every encoding should encode a unique value- we do not want 2 encodings of the same value)
- Want to have an easy comparison for equality of numbers, and easy determination of sign of number
The 2’s complement encoding scheme can be denotes as:
B2T
With the encoding scheme B2T, there is a 2-step algorithm (thus why it is called 2’s complement). that is often used to negate values (or to get the negative value that corresponds to some positive value). What are the two steps to the algorithm?
1) Invert all the bits (change 1’s to 0’s and 0’s to 1’s)
2) Add 1 to the result of step 1
Using B2T, negate the bit string “0101”:
1) Invert: 1010
2) Add 1: 1011
“0101” is a value of 5. “1011” is -5 in B2T
The 1’s complement encoding scheme can be denoted as”
B2O