Looks like no one added any tags here yet for you.
Why are numbers in the computer represented in 2's complement?
The number of bits available for representing a number is limited; it is not clear how to represent a negative number
A byte is
8 bits
An ASCII length
7 bits and sign bit is always 0
When does overflow happen?
If you add two positives and the leftmost bit turns out negative; If you add two negatives and the leftmost bit turns out positive
How do you know there is a carry?
Extra leftmost bit
How do you know there is borrow?
In a substraction A - B, B is greater than A (need to take 2's complement and do addition A + 2's of B)
What is a BCD?
Binary coded decimal; each decimal digit has a representation of two numbers per byte (that look just like the decimal number) and zeros to fill in the missing bytes
What format is used for floating point numbers?
IEEE Single Point Precision Format
What are the steps for IEEE?
Convert floating point number to binary (for the decimal, multiply the value of the decimal times 2 and only count the number before the decimal point, then multiply the result by 2 and so on until you have an equal amount of results as number of decimals); decide sign bit; move the decimal point to the right of the leftmost bit; do "excess-127" (127 + binary exponent); put it together = sign bit + exponent + mantissa
What is the binary conversion of 128?
1000 0000
OR
AND
The hexadecimal system represents numbers using about ____ as many digits as the binary system.
1/4
What is CRLF? (ASCII)
Newline
What are the three basic types of instruction operands?
Constants, CPU register designations, and references to memory locations.
Why do we not use signed magnitude to represent signed numbers in a computer?
We do not use signed magnitude to represent signed numbers in a computer because adding or subtracting two values in sign magnitude does not always lead to the correct result. Another reason is because the left most bit is used to indicate if a value is positive or negative while the magnitude bits indicate a value. This can make interpreting the value in sign magnitude extremely confusing and lead to incorrect interpretations.
What is the difference between a "carry in" and a "carry out"?
"Carry in" means there was a carry into the left most bit (sign bit) while "carry out" means there was a carry out of the left most bit. This occurs when adding two signed values. (In other words. If two values are added such as A + 7 the sum in decimal would be 17. Thus, 17 - 16 = 1. As a result, you would put down 1 to indicate the difference between the sum and 16 and carry one over to the next numerical place value to indicate a carry of 16.)
What is the difference between the term, "two's complement representation", and "calculating the two's complement of a number"?
The two's complement representation is the signed fixed length representation of a value. Calculating the two's complement of a number is taking a number that is assumed to be in an unsigned form and converting to a signed form within a fixed length.
Justify your agreement or disagreement to the following: "Signed magnitude cannot be used as a means to represent signed numbers in a computer."
Sign magnitude cannot be used to represent signed numbers in a computer because if you add two values in sign magnitude you can get an incorrect answer. Also, it uses the left most bit (sign bit) as a 1 to indicate a negative value whilst all other bits in the magnitude are supposed to indicate an integer representation. This can be incredibly hard to distinguish thus signed magnitude should not be used as a means to represent signed numbers in a computer.
Six (cap, its five) basic components of a computer
CPU, Memory (RAM), input, output, and AUX memory
What are the parts of a CPU?
Control unit, arithmetic logic unit, registers (storage locations)
Is memory linear or a grid?
Linear
What terminates the information stored in RAM?
RAM will lose its memory after the computer is powered off.
What are some examples of input devices?
Keyboard, mouse, microphone
What are examples of output devices?
Monitor, speakers, printer
What are some examples of aux storage?
Harddrive, flashdrive
What does "byte-addresable" mean?
Each byte in memory has its own address
Flat Memory Model
An approach to assigning memory addresses in which memory locations are described by single unsigned integers corresponding to linear positions.
Segmented Memory Model
An approach to assigning memory addresses in which primary storage is divided into equal sized segments called pages, identified by sequential nonnegative integers; each memory address depends on its segment number (chunks of memory)
Paging
A memory management scheme where a computer stores and retrieves data from secondary storage for use in main memory.
What is the instruction pointer?
eip; holds address of the next instruction to be performed.
What are the parts of "add sum, 5"? (Mneumonic + operand)
Add = mnemonic; sum, 5 = operand; both = instruction
Where are the instructions held in the instruction execution cycle?
RAM
Parts of Instruction Execution Cycle
Fetch (find out what is in eip and through address bus go into ram to get the corresponding bytes) Decode (In the control unit) Fetch operands Execute (Into the a/l unit) Store output
What are the 2 buses involved in the Instruction Execution Cycle?
Address and data
How are instructions stored in memory?
One byte has the mnemonic (opcode), the address of dest is stored, and then is source address (or value if it is immediate); information is stored in binary.
The bottleneck for the Instruction Execution Cycle
The system bus; everything we do goes through the system bus (CPU to MEMORY and back); 2^32 binary values at a time.
What does A/L Unit stand for?
Arithmetic/Logic Unit; gets information for memory or register receives data and perform calculation
What is the job of the CPU?
To direct traffic across the system bus.
What is the job of the CPU's control unit?
To interpret an opcode and directs the execution.
What is the control bus?
It tells us who is using the system bus at a point; monitors transmission of memory.
How many GB of data can be in the RAM?
4GB (2^32 = Address bus is 32-bit)
What is the unsigned range of values that can be addressed?
0 -> 4,294,967,295 (0 -> 2^32 - 1)
What are the 4 General Purpose Registers
eax, ebx, ecx, edx (32-bit)
What are the four Index Registers?
ESI (Source Index Registers), EDI (Destination Index Registers), ESP (Stack Pointer), EBP (Base Pointer); (32-bit) for both you can only get to the low orderword
What is the Instruction Pointer?
EIP
Pre-Fetching Instructions
CPU fetches instructions before a prior instruction is executed.
When does a stall in the pipeline occur?
When two instructions attempt to use the same register.
What bit is CF
0
What bit is PF
2
What bit is ZF
6
What bit is SF
7
What bit is DF
10
What bit is OF
11
What is the maximum capacity IN HEX on a 32-bit system bus?
00 00 00 00 -> FF FF FF FF
The EAX register is sometimes known as the _________. Why?
Accumulator; because it is the destination of arithmetic results.
What are the three parts of the accumulator?
AX (0-15 bit), AH (8-15), AL (0-7)
What criterion must be satisfied for a value to be stored in Little ENDian?
It must be a numerical value (scaled value), it must be stored in memory, and it must be multibyte.
What is an instruction?
Statement that is translated by the assembler into machine code
What is a directive?
Indicates where to take action but does not result in execution of machine code
What does a macro do?
Calls a chunk of code to be exevuted
What character starts a comment in assembly code?
;
Is .586 an instruction or a directive?
Directive
Is mov eax, val an instruction or a macro?
Instruction
Is input prompt1, string, 40 an instruction or a macro?
Macro
Do all directives start with a '.'?
No
Is DWORD a macro or a directive?
Directive (allocates memory)
What are the main parts of a typical instruction? (4)
Name, mnemonic, operands, comment
If we have EAX = 0x 00 00 10 04 and the instruction mov sum, eax, how is EAX value stored in sum?
Little ENDian; 04 10 00 00
In Little ENDian, the destination stores the least significant byte (rightmost) from the source in the ________ memory address.
Smallest
How many bytes of memory does a word allocate?
2
How many bytes of memory does a dword allocate?
4
How many bytes of memory does a qword allocate?
8
If in the data segment you declare: char1 BYTE 'q', and in the code segment it says mov ax, char1, what would be the error?
Size mismatch (or size ambiguity; ax is a 16-bit register while char1 is an 8-bit register)
What are the three types of instruction operands?
Constants (or immediate; add eax, 5), CPU Register (add eax, 5), memory location (add sum, eax)
What are the three general addressing modes?
Immediate, register, memory
What are the two types of memory addressing modes?
Direct and register indirect
What addressing mode is add sum, eax using?
Direct, register
What addressing mode is add [ebx], eax using?
Register indirect, register
What addressing mode is add ax, 6 using?
Immediate
What addressing mode is add 6, ax using?
N/A (An immediate value can not be a destination)
What addressing mode is add [ebx], 20 using?
Size mismatch (neither [ebx] or 20 indicate size, [ebx] because it is a pointer while 20 because it is an immediate value)
What addressing mode is add BYTE PTR [ebx], 20?
Register indirect
What could "io.h" be compared to in c++?
Header file
What does atod do?
It scans a string starting at source for digits and the 2's complement value is stored at eax (default destination)
What does dtoa do?
Takes doubleword at source and converts it into a string of ASCII characters at destination
If we are given dtoa dest, source and the source value is 103 (decimal) what is the ASCII value?
31 30 33 h
What does atow do?
Scans the string starting at source and turns into a 16-bit digit corresponding 2's complement value and places it at ax (default destination)
What does wtoa do?
Takes a numerical 16-bit value from source (register or memory) and converts it into ASCII characters, storing it into destination
How many ASCII characters are needed to store a range of 16-bit values? (wtoa)
6
A dtoa starts with a doubleword and produces a __-byte-long string
11
The input from the user and a null terminator character.
Input macro: What happens if you enter a string larger than the length specified?
The extra characters are truncated.
For instructions, you _____ have both source and destination in memory.
cannot
Does mov alter any flags?
No
What are the three fields of Mod R/M?
Mod, register, and R/M (register/memory)
In an AL accumulator, how many bytes are reserved for opcode? How many bytes are reserved for object code?
1; 5
In general, with direct memory mode "2+" always means "2 + __ "
4
In general, with indirect memory mode "2+" always means "2 + __ "
0
Is the REX Prefix part of the opcode for 64-bit processors? (Page 82, Figure 4.4)
No (it is still an extra byte though)