0% found this document useful (0 votes)
95 views3 pages

CS401 Practical Assignment

This document provides an assembly language program that calculates the sum of all even numbers from 1 to N, where N is the largest digit of the given VUID (7 in this case). The program uses jumps and labels to implement the necessary loops and conditionals. It stores the final sum in a variable named 'sum'. It takes the last digit of the given VUID as the largest number, initializes registers and variables, then loops through each number from 1 to N, checking if it is even using AND and comparing to 0, adding to the running sum 'ax' if even. It decrements the counter, compares to 0 and jumps back if not done. Finally it stores the final sum in the 'sum' variable and

Uploaded by

Shahid Ameen
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)
95 views3 pages

CS401 Practical Assignment

This document provides an assembly language program that calculates the sum of all even numbers from 1 to N, where N is the largest digit of the given VUID (7 in this case). The program uses jumps and labels to implement the necessary loops and conditionals. It stores the final sum in a variable named 'sum'. It takes the last digit of the given VUID as the largest number, initializes registers and variables, then loops through each number from 1 to N, checking if it is even using AND and comparing to 0, adding to the running sum 'ax' if even. It decrements the counter, compares to 0 and jumps back if not done. Finally it stores the final sum in the 'sum' variable and

Uploaded by

Shahid Ameen
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

CS401 (Practical) Assignment # 1

Name: SHAHID AMEEN

VUID: BC210415570
Question:

Write an assembly language program that calculates the sum of all even
numbers from 1 to N, where N is the largest digit of your VUID. Use jumps
and labels to implement the necessary loops and conditionals. Store the final
sum in a variable named sum?
We write the code for display the result in the compiler your vu id sum:

Assembly language code:

[org 0x0100]
jmp start

number: db 7
sum: db 0

start:
mov bx,[number]
mov cx,7
mov ax,0

checking:
and bx,1
cmp bx,0
jnz skip
add ax,cx

skip:
sub cx,1
mov bx,cx
cmp cx,0
jnz checking

mov [sum],ax

mov ax,0x4c00 ;termination of program

int 0x21

sample screenshot with last four digits is as :

Sample screen shot of original vu id greatest number with sum:

You might also like