0% found this document useful (0 votes)
7 views

COM 323 ACTIVITY_1

The document compares assembly language with high-level languages, detailing differences and providing examples of simple programs in both. It describes the EMU8086 assembler environment, including its features, installation steps, and properties. Additionally, it covers various assembly programming concepts, including addressing modes, commands, control flow, and common functions in assembly language.

Uploaded by

Kaosara Olalere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

COM 323 ACTIVITY_1

The document compares assembly language with high-level languages, detailing differences and providing examples of simple programs in both. It describes the EMU8086 assembler environment, including its features, installation steps, and properties. Additionally, it covers various assembly programming concepts, including addressing modes, commands, control flow, and common functions in assembly language.

Uploaded by

Kaosara Olalere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

MATRIC NO: 19/69/0148

COM 323 ACTIVITY

Title: Comparing Assembly Language with high level language

Task 1

1. Identify differences between High level and Assembly language.

2. Write a simple Hello World program using any high level language and assembly language.

# Hello World program in Python

print("Hello, World!")

1
Title: Introduction to Assembly Programming

Task 2

1. Describe the emu8086 assembler environment and properties.

The EMU8086 assembler environment is specifically designed for programming and simulating applications
for the 8086 microprocessor. This environment provides an integrated development environment (IDE) that
facilitates the writing, debugging, and execution of assembly language programs. Below are the key features
and properties of the EMU8086 assembler environment:

Key Features of EMU8086 Assembler Environment

1. Integrated Development Environment (IDE):


o EMU8086 offers a user-friendly interface that combines a code editor, assembler, and
debugger in one application, making it easier for beginners and experienced programmers to
work with assembly language.
2. Syntax Highlighting:
o The code editor provides syntax highlighting for assembly language keywords, making the
code more readable and helping programmers quickly identify instructions, labels, and
comments.
3. Built-in Assembler:
o The environment includes a built-in assembler that converts assembly language code into
machine code, which can be executed by the emulator.
4. Emulation and Simulation:
o EMU8086 simulates the 8086 microprocessor, allowing users to run and test their assembly
programs without the need for actual hardware. This is particularly useful for learning and
debugging.
5. Debugging Features:
o The environment includes debugging capabilities such as step-by-step execution,
breakpoints, and memory inspection, allowing users to monitor the program flow and
diagnose issues easily.
6. Support for DOS Interrupts:
o EMU8086 supports various DOS interrupts, enabling users to perform input and output
operations, file handling, and other system-level functions in their programs.
7. Example Programs:
o The IDE comes with several example programs that help users understand how to write
assembly language code and use different features of the environment effectively.
8. Hexadecimal and Decimal Support:
o The environment allows users to work with both hexadecimal and decimal numbers, which
is useful for low-level programming.
9. Easy Code Navigation:
o The code editor supports features like line numbering and easy navigation, helping
programmers quickly find specific parts of their code.
10. Export and Import Options:
o Users can export their projects and programs to different file formats for sharing or further
processing.

Properties of EMU8086 Assembler Environment

1. Compatibility:
o EMU8086 is compatible with Windows operating systems, allowing it to run on most
modern PCs.
2. Small Memory Footprint:

2
o The environment is lightweight, requiring minimal system resources, making it accessible
even on older machines.
3. User-Friendly Interface:
o The interface is intuitive, making it easy for beginners to navigate and start programming
without extensive prior knowledge.
4. Customizable Settings:
o Users can customize the editor settings, such as font size and color schemes, to suit their
preferences.
5. Real-Time Execution:
o The emulator executes programs in real time, allowing users to see the results of their code
immediately.
6. Rich Documentation:
o EMU8086 comes with extensive documentation and help files that provide guidance on
using the assembler and understanding assembly language concepts.

2. Describe the steps involved in installing and launching the assembly

Steps to Install and Launch EMU8086

1. Download EMU8086

1. Visit the Official Website:


o Go to the official EMU8086 website: EMU8086 Official Website.

2. Download the Installer:


o Look for the download section on the website.
o Click on the appropriate link to download the EMU8086 installer (usually named something
like emu8086.zip).

2. Extract the Downloaded File

1. Locate the Downloaded ZIP File:


o Go to the directory where the EMU8086 ZIP file was downloaded (usually the Downloads
folder).

2. Extract the ZIP File:


o Right-click on the downloaded ZIP file and select Extract All (or use any extraction tool
like WinRAR, 7-Zip, etc.).
o Choose a destination folder where you want to extract the files (for example, C:\EMU8086).

3. Install EMU8086

1. Navigate to the Extracted Folder:


o Open the folder where you extracted the files.

2. Run the Installer:


o Find the installation file (usually named setup.exe or similar).
o Double-click on the installer to start the installation process.

3. Follow Installation Instructions:


o Follow the on-screen instructions to install EMU8086.
o Choose the installation directory if prompted, or accept the default location.
o Click Next or Finish when prompted to complete the installation.

4. Launch EMU8086

1. Find the EMU8086 Icon:


3
o After installation, you should find an EMU8086 icon on your desktop or in the Start Menu.

2. Open EMU8086:
o Double-click the EMU8086 icon to launch the program.

5. Using EMU8086

1. Create a New Project:


o Once EMU8086 is open, you can create a new project by selecting File > New.

2. Write Your Code:


o You can start writing your assembly language code in the provided editor.

3. Assemble and Run:


o Use the Compile button to assemble your code.
o Click the Run button to execute your program and see the output.

Title: A program to display all the 26 English alphabets on the screen, in uppercase form

Task 3

1. Write any interactive program that request for input from the user, accepts input and give an output.

4
Title: Display of 256 ASCII characters

Task 4

1. Write a program that will display output on the screen. (Numeric Output)

Title: Display the message WELCOME TO ASSEMBLY LANGUAGE PROGRAMMING CLASS

Task 5

1. Write a program that will display sequence of characters on the screen.

5
Title: Displaying letter G on the Screen

Task 6

1. Write a program that will display alphabets on the screen.

Title: Using addressing node in an assembly program

Task 7

1. Briefly explain the two addressing nodes.

1. Immediate Addressing Mode

In immediate addressing mode, the operand is specified explicitly within the instruction itself rather than
being stored in a register or memory location. This means that the instruction contains the actual value to be
used.

6
2. Direct Addressing Mode

Definition: In direct addressing mode, the operand's address is specified directly in the instruction. The
instruction points to a specific memory location where the operand is stored.

2. List and explain various commands and registers in an assembler

Common Commands (Instructions)

1. Data Movement Instructions


o MOV: Transfers data from one location to another.
 Syntax: MOV destination, source
 Example: MOV AX, BX (copies the value in BX to AX).
o PUSH: Places a value onto the stack.
 Syntax: PUSH operand
 Example: PUSH AX (pushes the contents of AX onto the stack).
o POP: Removes a value from the stack and places it in a register.
 Syntax: POP destination
 Example: POP AX (pops the top value from the stack into AX).

2. Arithmetic Instructions
o ADD: Adds two operands.
 Syntax: ADD destination, source
 Example: ADD AX, 5 (adds 5 to the value in AX).
o SUB: Subtracts one operand from another.
 Syntax: SUB destination, source
 Example: SUB AX, BX (subtracts BX from AX).
o MUL: Multiplies unsigned integers.
 Syntax: MUL operand
 Example: MUL BX (multiplies AX by BX, result in DX:AX).

3. Logical Instructions
o AND: Performs a bitwise AND operation.
 Syntax: AND destination, source
 Example: AND AX, 0FFh (performs a bitwise AND between AX and 0FFh).
o OR: Performs a bitwise OR operation.
 Syntax: OR destination, source
 Example: OR AL, 1 (sets the least significant bit of AL).
o XOR: Performs a bitwise XOR operation.
 Syntax: XOR destination, source
 Example: XOR AX, AX (clears the register AX).

4. Control Flow Instructions


o JMP: Unconditional jump to a specified location.
 Syntax: JMP label
 Example: JMP start (jumps to the label start).
o JE/JZ: Jump if equal (or zero).
 Syntax: JE label or JZ label
 Example: JE end (jumps to end if the zero flag is set).
o CALL: Calls a procedure (subroutine).
 Syntax: CALL label
 Example: CALL myProcedure (calls the procedure myProcedure).
o RET: Returns from a procedure.
 Syntax: RET
 Example: RET (returns control to the calling procedure).

7
5. Comparison Instructions
o CMP: Compares two operands.
 Syntax: CMP operand1, operand2
 Example: CMP AX, BX (compares AX and BX).
o TEST: Performs a bitwise AND and sets flags.
 Syntax: TEST operand1, operand2
 Example: TEST AX, 1 (tests if the least significant bit of AX is set).

Common Registers

1. General-Purpose Registers
o AX: Accumulator register; used for arithmetic operations.
o BX: Base register; often used for addressing data in memory.
o CX: Count register; commonly used for loop counters and string operations.
o DX: Data register; used in arithmetic operations and I/O operations.

2. Segment Registers
o CS: Code Segment; points to the segment containing the executable code.
o DS: Data Segment; points to the segment containing data variables.
o SS: Stack Segment; points to the segment containing the stack.
o ES: Extra Segment; often used for string operations.

3. Pointer Registers
o SP: Stack Pointer; points to the top of the stack.
o BP: Base Pointer; points to the base of the stack frame for the current procedure.

4. Index Registers
o SI: Source Index; used for string operations.
o DI: Destination Index; also used for string operations and data movement.

5. Instruction Pointer
o IP: Instruction Pointer; points to the next instruction to be executed.

6. Flags Register
o FLAGS: Contains status flags that indicate the outcome of operations (like zero, carry,
overflow, and sign flags).

Title: Assembly Language Program using difference program flow control

Task 8

1. Identify the similarities and the differences observed between the two program control flow.

Similarities

1. Execution Control:
o Both branching and looping mechanisms control the flow of execution, determining which
set of instructions will be executed based on certain conditions.

2. Use of Conditions:
o Both structures often rely on conditions to determine their path. For example, branching can
depend on a specific condition (like zero or non-zero), while looping often continues until a
condition is met.

3. Alteration of Instruction Sequence:


o Both techniques can alter the normal sequential execution of instructions. Instead of
executing instructions linearly, they allow for jumping to different parts of the program.

8
4. Use of Jumps:
o Both control flow types utilize jump instructions (like JMP, JE, JNE, etc.) to navigate
through code. This is foundational in assembly language for directing program flow.

Differences

1. Purpose:
o Branching: Typically used for making decisions (e.g., if-else statements) where the
program executes different code paths based on certain conditions.
o Looping: Used to repeat a block of instructions multiple times until a specific condition is
satisfied (like for-loops or while-loops).

2. Execution Frequency:
o Branching: Executes once per decision point and moves to a different part of the code
based on the outcome.
o Looping: May execute multiple times, repeatedly running the same block of instructions
until the termination condition is met.

3. Structure:
o Branching: Usually involves a single conditional check followed by multiple possible
outcomes. It may lead to different sections of code based on the condition.
o Looping: Involves an entry condition (to start the loop) and an exit condition (to terminate
the loop), and generally has a structure that allows for repeated execution of the same code
block.

4. Example Instructions:
o Branching: Instructions like JE (jump if equal), JNE (jump if not equal), and JG (jump if
greater) are typical for conditional branching.
o Looping: Instructions like LOOP, JCXZ (jump if CX register is zero), or using a
combination of CMP and JMP for creating loops.

Title: Library of common functions

Task 9

1. What are the library of common functions.

 Display Output:

 AH = 09h - Display String:


o Displays a string terminated by $ (like "Hello$").
o Usage: Set AH to 09h, DX to the address of the string, and call INT 21h.
 AH = 02h - Display Character:
o Displays a single character in DL.
o Usage: Set AH to 02h, DL to the ASCII character to display, and call INT 21h.

 Accept Input:

 AH = 01h - Input Character with Echo:


o Reads a single character from the keyboard and echoes it to the screen.
o Usage: Set AH to 01h, call INT 21h, and the character will be returned in AL.
 AH = 0Ah - Input String:
o Reads a string from the keyboard and stores it in a buffer.

9
o Usage: Set AH to 0Ah, DX to the buffer address, and call INT 21h. The first byte in the
buffer is the maximum string length.

 File Operations:

 AH = 3Dh - Open File:


o Opens a file for reading or writing.
o Usage: Set AH to 3Dh, DX to the filename, and call INT 21h. File handle is returned in AX.
 AH = 3Eh - Close File:
o Closes an open file.
o Usage: Set AH to 3Eh, BX to the file handle, and call INT 21h.

 Program Termination:

 AH = 4Ch - Terminate Program:


o Ends the program and returns control to the operating system.
o Usage: Set AH to 4Ch, set AL to the return code (optional), and call INT 21h.

 Memory Allocation:

 AH = 48h - Allocate Memory:


o Allocates memory for the program.
o Usage: Set AH to 48h, BX to the number of paragraphs needed, and call INT 21h. Segment
address is returned in AX.

b. List any 5 of the functions and their uses

1. INT 21h - AH = 01h: Input Character with Echo

 Use: Reads a single character from the keyboard and displays it on the screen.
 Registers:
o Set AH to 01h.
o The character entered is returned in AL.
 Example:

asm
Copy code
mov ah, 01h ; Set function to read character with echo
int 21h ; Call DOS interrupt
; The character is now in AL

2. INT 21h - AH = 02h: Display Character

 Use: Displays a single character specified in the DL register on the screen.


 Registers:
o Set AH to 02h.
o Load DL with the ASCII character to display.
 Example:

asm
Copy code
mov ah, 02h ; Set function to display character
mov dl, 'A' ; Character to display
int 21h ; Call DOS interrupt

3. INT 21h - AH = 09h: Display String

10
 Use: Displays a string of characters on the screen, terminated by a $ character.
 Registers:
o Set AH to 09h.
o Load DX with the address of the string.
 Example:

asm
Copy code
mov ah, 09h ; Set function to display string
lea dx, message ; Load address of the message
int 21h ; Call DOS interrupt

4. INT 21h - AH = 0Ah: Input String

 Use: Accepts a string input from the user and stores it in a buffer.
 Registers:
o Set AH to 0Ah.
o Load DX with the address of the buffer (the first byte indicates the maximum length).
 Example:

asm
Copy code
mov ah, 0Ah ; Set function to input string
lea dx, buffer ; Load address of the buffer
int 21h ; Call DOS interrupt

5. INT 21h - AH = 4Ch: Terminate Program

 Use: Ends the program and returns control to the operating system.
 Registers:
o Set AH to 4Ch.
o Optionally set AL to an exit code.
 Example:

asm
Copy code
mov ah, 4Ch ; Set function to terminate program
mov al, 00h ; Exit code (optional)
int 21h ; Call DOS interrupt

Title: Library of common functions continued

Task 10

1. Write a program to accept a positive number and display it using library of common functions.

11
Title: Interrupt

Task 11

1. What are interrupt? Interrupt is a mechanism that allows the CPU to pause its current execution
and respond to an external or internal event, like input/output requests, hardware failures, or
software requests. Interrupts enable the system to handle asynchronous events effectively and
prioritize certain tasks over others.
b. What are they used for in assembly language?

 Accessing System Services:

 Interrupts provide a way for programs to request services from the operating system. For example, in
DOS assembly language, the INT 21h interrupt gives access to a range of functions, such as reading
from or writing to files, handling input/output, and more.

 Handling External Hardware Events:

 Hardware interrupts allow the CPU to respond to events from external devices, like keyboards,
timers, and network interfaces. When a key is pressed, a keyboard interrupt (like INT 09h in x86)
allows the CPU to momentarily pause other tasks, read the keypress, and store it for the program to
use.

 Managing Exceptions and Errors:

 Interrupts are used to handle critical errors or exceptions, such as division by zero, invalid memory
access, or illegal instructions. When the CPU encounters such issues, it automatically invokes an
interrupt to run an error-handling routine.

 Creating Efficient I/O Operations:

 Rather than constantly polling (checking) if a device needs attention, a program can wait for an
interrupt, reducing CPU load. For example, if a program is waiting for a network packet, it can
continue with other tasks and get interrupted only when data arrives, making it efficient and
responsive.

 Supporting Multitasking and Process Switching:

 In operating systems that support multitasking, interrupts allow for task switching by periodically
saving the state of one task and loading another. Timer interrupts (like INT 08h in x86 systems)
allow the OS to manage task scheduling.

 Providing Real-Time Responses:

12
 In real-time systems, interrupts ensure the CPU can react immediately to time-sensitive events. An
interrupt-driven response is vital in applications like embedded systems (e.g., controllers for
industrial machines, medical devices).

2. List 5 interrupt that can be flagged in assembly language & their functions
i. INT 10h - Video Services
ii. INT 13h - Disk Services
iii. INT 16h - Keyboard Services
iv. INT 17h - Printer Services
v. INT 21h - DOS Services

13

You might also like