0% found this document useful (0 votes)
3 views4 pages

Assignment Computer Architecture

The document provides assembly programming documentation for three programs: calculating the GCD of two numbers using the Euclidean algorithm, summing all odd numbers within a specified range, and dividing a number by 7 while printing the result as an ASCII string. Each program includes objectives, explanations of the algorithms used, and mentions adherence to coding standards with student IDs included in comments. Code snippets and output screenshots are referenced for each program to illustrate functionality.

Uploaded by

2020010002606
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)
3 views4 pages

Assignment Computer Architecture

The document provides assembly programming documentation for three programs: calculating the GCD of two numbers using the Euclidean algorithm, summing all odd numbers within a specified range, and dividing a number by 7 while printing the result as an ASCII string. Each program includes objectives, explanations of the algorithms used, and mentions adherence to coding standards with student IDs included in comments. Code snippets and output screenshots are referenced for each program to illustrate functionality.

Uploaded by

2020010002606
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/ 4

Assembly Programming Documentation

Programs
1. To calculate the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
2. To compute the sum of all odd numbers within a given range.
3. To divide a number by 7 and print the result as an ASCII string.
Program 1: GCD of Two Numbers

1.1 Objective:

To calculate the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.

1.2 Explanation:

This program calculates the GCD of two numbers using the Euclidean algorithm. The algorithm repeatedly divides the larger

number by the smaller one, replacing the larger number with the remainder. This process continues until the remainder becomes

zero, at which point the smaller number is the GCD. The program is implemented in x86 assembly and uses basic arithmetic

operations such as division and comparison. Registers are used to store intermediate results, and the final GCD is stored in the

`result` variable. To make the output user-friendly, the result is converted into an ASCII string and printed. This program also

includes the student ID in the comments for identification.

1.3 Code and Output Screenshot of program 1:

CODE OUTPUT
Program 2: Sum of Odd Numbers in a Range

2.1 Objective:

To compute the sum of all odd numbers within a given range.

2.2 Explanation:

This program calculates the sum of odd numbers within a specified range. The range is defined using the `start` and

`end` variables. The program iterates through all numbers in the range, checking whether each number is odd using a bitwise AND

operation (`test al, 1`). Odd numbers are added to an accumulator (`ecx`) that stores the running total. After processing all numbers,

the total sum is stored in the `sum` variable, converted to ASCII, and printed. This ensures accurate and user-friendly output. The

program is written in x86 assembly and adheres to proper coding standards. The student ID is prominently included in the comments

for identification purposes.

2.3 Code and Output Screenshot of Program 2:

CODE OUTPUT
Program 3: Division of a Number by 7

3.1 Objective:

To divide a number by 7 and print the result as an ASCII string.

3.2 Explanation:

This program divides a given 16-bit number (student number) by 7 and prints the quotient to the console. The program uses the `div`

instruction to perform the division operation, storing the quotient in the `eax` register and the remainder in

`edx’. A custom subroutine converts the quotient into an ASCII string. The result is printed along with a descriptive message. This

implementation demonstrates an efficient approach to division and ASCII conversion in x86 assembly. Proper coding standards,

such as meaningful comments and organized code structure, are followed. The student ID is included in the comments to ensure

identification. For the input 70, the program calculates a quotient of 00010, which is printed to the console.

3.3 Output Screenshot of Program 3:

CODE OUTPUT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy