Assembly Language Fundamentals: Registers, Operands, and Data Types

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.73 KB

Assembly Language Fundamentals: Key Concepts and Definitions

1. Clock Frequency and Cycle Time

A clock that oscillates 1 million times per second (1 MHz) produces a clock cycle duration of $10^{-6}$ seconds (1 microsecond).

2. General-Purpose Registers (8-bit, 16-bit, and 32-bit Access)

The general-purpose registers that can be accessed in 8 bits, 16 bits, and 32 bits are: EAX, EBX, ECX, and EDX.

3. Purpose of EAX and ECX Registers

These registers serve specific roles in CPU operations:

  • EAX – Accumulator: Automatically used by multiplication and division instructions. It is often referred to as the extended accumulator register.
  • ECX – Loop Counter: The CPU automatically uses ECX as a counter for loop instructions.

4. Reserved Words and Identifiers in Assembly

Examples illustrating the difference between reserved keywords and user-defined identifiers:

  • Reserved Words: MOV, ADD, and MUL (Instructions defined by the language).
  • Identifiers: lineCount, firstValue (User-defined variables or labels).

5. Examples of Instructions by Operand Count

Assembly instructions can be classified based on the number of operands they require:

  1. No Operand: The STC instruction, for example, has no operands:
    stc ; set Carry flag
  2. One Operand: The INC instruction has one operand:
    inc eax ; add 1 to EAX
  3. Two Operands: The MOV instruction has two operands (destination, source):
    mov count, ebx ; move EBX (source operand) to count (destination operand)

6. Comparing Array Elements

Do the following two arrays contain the same elements?

list1 BYTE 10, 22, 41h, 00000010b
list2 BYTE 0Ah, 20h, 'A', 22h

No. The arrays do not contain the same elements. A comparison of the byte values shows:

Indexlist1 Value (Decimal)list2 Value (Decimal)
110 (0Ah)10 (0Ah)
222 (16h)32 (20h)
365 (41h)65 ('A' = 41h)
42 (00000010b)34 (22h)

7. Correcting an Assembly Program for 32-bit Addition

The following program adds two 32-bit integers (5 and 6) using the EAX register and ensures a clean exit. The structure below represents the standard corrected format for this task:

.386
.model flat, stdcall
.stack 4096

ExitProcess PROTO, dwExitCode:DWORD

.code
main PROC
    mov eax, 5  ; Load the first 32-bit integer into EAX
    add eax, 6  ; Add the second 32-bit integer to EAX
    INVOKE ExitProcess, 0 ; Terminate the program successfully
main ENDP
END main

8. Converting Decimal to IEEE Single Precision Floating Point

Conversion of $(13.25)_{10}$

The process involves converting the number to binary, normalizing it, determining the biased exponent, and assembling the 32-bit representation (Sign, Exponent, Mantissa).

The final IEEE Single Precision floating-point binary number is:

0 10000010 10101000000000000000000
  • Sign Bit (S): 0 (Positive)
  • Exponent (E): 10000010 (Biased exponent)
  • Mantissa (M): 10101000000000000000000

9. Calculating Array Size Using the Current Location Counter ($)

To calculate the size of the list array, which contains 32-bit double words (DWORDs), the Current Location Counter ($) is used to find the address difference, which is then divided by the size of the element (4 bytes).

list DWORD 10000000h, 20000000h, 30000000h, 40000000h
ListSize = ($ - list) / 4

10. Ranges of Unsigned and Signed Words

The following table details the storage ranges for signed and unsigned byte and word data types:

Storage TypeRange (Low–High)Number of BitsPowers of 2 Representation
Signed Byte-128 to +1278$-2^7$ to $(2^7 - 1)$
Signed Word-32,768 to +32,76716$-2^{15}$ to $(2^{15} - 1)$
Unsigned Byte0 – 25580 to $(2^8 - 1)$
Unsigned Word0 – 65,535160 to $(2^{16} - 1)$

Related entries: