Core Concepts in Computer Architecture and Assembly
CPU Fundamentals and Timing
Clock Cycles and Frequency
A clock that oscillates 1 million times per second (1 MHz) produces a clock cycle of 1 microsecond (1 μs), which equals 10-6 seconds per cycle.
Instruction Execution Pipeline
The steps for executing a machine instruction are:
- Fetch the instruction.
- Decode the instruction.
- Fetch the operand (if any).
- Execute the instruction.
- Store the result or output.
Cache Memory Operations
Cache memory is a small, fast memory used to temporarily store frequently accessed data or instructions to speed up CPU operations.
- A cache hit occurs when the CPU finds the required data in cache memory.
- A cache miss occurs when the data is not found and must be fetched from main memory.
Assembly Language Basics
General-Purpose Registers
The general-purpose registers accessible in 8, 16, and 32 bits include AX, BX, CX, and DX.
- The EAXregister is used as an accumulator for arithmetic, logic operations, and I/O.
- The ECXregister is primarily used as a counter in loops and string instructions.
Reserved Words and Identifiers
Examples of reserved words are DWORD, BYTE, and WORD. Examples of identifiers are count, index, and sum.
Instruction Operand Types
Instructions can be categorized based on the number of operands:
- No operand: stc
- One operand: inc eax
- Two operands: mov eax, 5
Data Representation and Memory
Array Data Comparison
The two arrays, list1 (10h, 22h, 41h, 00000010b) and list2 (0Ah, 20h, 'A', 22h), do not contain the same elements.
Numeric Data Ranges
Standard numeric ranges for common data types:
- Signed byte: -27 to 27 - 1 (-128 to 127)
- Unsigned byte: 0 to 28 - 1 (0 to 255)
- Signed word: -215 to 215 - 1 (-32768 to 32767)
- Unsigned word: 0 to 216 - 1 (0 to 65535)
Array Size Calculation
For the array definition: list DWORD 1000000h, 2000000h, 3000000h, 4000000h, the size calculation is:
Size = ($ - list) / 4 (where $ is the current address and 4 is the size of a DWORD in bytes).
IEEE 754 Single Precision Conversion (13.25)
Steps to convert decimal 13.25 to IEEE 754 single precision format:
- Sign bit = 0 (positive)
- 13 in binary = 1101
- 0.25 in binary = .01
- Combined = 1101.01
- Normalized form: 1.10101 × 23
- Exponent calculation: 3 + 127 (Bias) = 130. Binary representation: 10000010
- Mantissa (Fractional part): 10101000000000000000000(23 bits)
- Final IEEE 754 representation: 0 10000010 10101000000000000000000
Assembly Code Example: 32-bit Addition
Corrected assembly code to add two 32-bit numbers (5 + 6):
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
    mov eax, 5
    add eax, 6
    INVOKE ExitProcess, 0
main ENDP
END main
 
 English with a size of 3.56 KB
English with a size of 3.56 KB