Lab 1
Lab 1
Course Instructor:
Basic Computer Architecture refers to the fundamental structure of a computer system, which
includes several key components:
● Processor (CPU): The core component responsible for performing operations and
executing instructions.
● Memory: Stores data and instructions that the processor accesses and manipulates.
● I/O Devices: Facilitate communication between the computer and the external world,
such as peripherals.
● Buses (Address, Data, and Control): These connect the processor to memory and other
devices:
o Address Bus: Unidirectional, tells memory which data to access.
o Data Bus: Bidirectional, moves data between memory and processor.
o Control Bus: Coordinates read/write operations and synchronizes data flow.
● Registers: Small, fast storage locations within the CPU for temporary data handling
during operations.
Memory
The Memory Dimension in computer architecture refers to how memory is organized and
described. Memory is defined by two key dimensions: the cell width, which indicates how many
bits each memory cell can store (commonly 8 bits or a byte), and the number of cells, which
specifies the total storage capacity. Together, these dimensions determine the overall structure
and capacity of memory, similar to how the width and depth of a well describe its total volume.
● Memory is divided into cells, each storing a fixed number of bits (e.g., 8-bit or 16-bit
cells).
● The data bus width typically matches the cell width for efficient operations.
● Memory is described by the number of cells and their size, determining the total
capacity.
Machine language is a pattern of bits that represent the OPCODE and operands, directly
executable by the CPU. The following is a short machine language program of the IBM PC.
Assembler
It is a system program which converts the assembly language program instructions into
machine executable instructions. For example: Microsoft Macro Assembler (MASM), Borland
Turbo Assembler (TASM), Open Source Netwide Assembler (NASM) etc.
MASM
The Microsoft Macro Assembler (MASM) is an x86 assembler for MS-DOS and
Microsoft
Windows. It supports a wide variety of macro facilities and structured programming idioms,
Including high-level functions for looping and procedures. Later versions added the capability of
producing programs for Windows.
TASM
Turbo Assembler (TASM) is an x86 assembler package developed by Borland. It is used
with
Borland's high-level language compilers, such as Turbo Pascal, Turbo Basic and Turbo C. The
Turbo Assembler package is bundled with the linker, Turbo Linker, and is interoperable with the
Turbo Debugger.
NASM
The Net wide Assembler (NASM) is an assembler and disassemble for the Intel x86
architecture. It can be used to write 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. NASM
is considered to be one of the most popular assemblers for Linux and is the second most popular
assembler overall, behind MASM.
NASM was originally written by Simon Tatham with assistance from Julian Hall, and is
currently maintained by a small team led by H. Peter Anvin.
Emulators
EMU 8086
Emulator allows computer program to run on a platform (computer architecture
and/or operating system) other than for which they were originally developed unlike the
simulation which only attempts to reproduce a program's behavior, emulation attempts to
model to various degrees the state of device being emulated.
EMU8086 is emulator which emulates the behavior of 8086 machine. Emu8086 IDE contains
built in assembler which is compatible with syntax of MASAM, TASAM and few other
assemblers.
It also contains debugger which can be used to debug executable program. In emu8086 one can
emulate each instruction of program one by one and can views the value of registers, flags and
variable changed by instruction.
Dos Box
Linker
Linker or link editor is a program that takes one or more objects generated by a
compiler and combines them into a single executable program. When a program
comprises multiple object files, the linker combines these files into a unified executable
program.
Linkers can take objects from a collection called a library. Some linkers do not include
the whole library in the output; they only include its symbols that are referenced from
other object files or libraries.
Turbo Assembler
The basic steps required to create, assemble, link and debug programs using MS Notepad
and the Borland Turbo C tools TASM, TLINK and TDEBUG, respectively. Each step requires
certain command parameters and programs to be run in order to accomplish on-line debugging.
Installation
● NASM
https://genrica.com/html5CSS3/Assembler_NASM_Installation_Usage_Guide.aspx
● Youtube
https://www.youtube.com/watch?v=91Vv-GKe57g
Activity:
Draw the following diagram on page or chart and bring to next class
This part of the manual introduces the basics of writing, saving, and running 8086 assembly
language code using the Emu8086 software. It will guide you through setting up Emu8086,
viewing registers, writing simple assembly code, and running it. The manual also includes an
initial lab assignment for hands-on practice.
1. Open Emu8086 and start a new file by clicking on `File > New`.
2. Enter the following simple assembly code to add two numbers:
```asm
; Simple program to add two numbers
Viewing Registers:
AX, BX, CX, DX are general-purpose registers used for various operations (e.g., arithmetic, data
storage).
SP, BP, SI, DI are special-purpose registers, commonly used for stack operations and memory
indexing.
Viewing Memory:
The memory panel allows you to see what values are stored in specific memory addresses.
You can toggle between different memory segments (code, data, stack).
Lab Observation: Write down the values in the registers after each step of program execution,
especially after the `ADD AX, BX` instruction. You should observe that the sum of 5 and 3 is
stored in the AX register.
Objective:
Write and execute an assembly program to perform addition, subtraction, multiplication, and
division of two numbers.
Assignment Description:
1. Open Emu8086 and create a new program.
2. Write a program to perform the following tasks:
- Load the value 10 into register AX.
- Load the value 2 into register BX.
- Perform the following arithmetic operations:
- Addition: Add AX and BX, store the result in AX.
- Subtraction:Subtract BX from AX, store the result in AX.
- Multiplication: Multiply AX by BX, store the result in AX.
- Division: Divide AX by BX, store the quotient in AX and remainder in DX.
4. Assemble and run the program step-by-step, noting down the changes in registers after each
operation.
Sample Code:
```asm
; Assembly program for arithmetic operations
Write a brief report noting the values of the registers after each operation.
Make sure to practice using the Step-by-Step execution mode in Emu8086. This will help you
observe how each instruction affects the registers and flags.