KEMBAR78
CS401 Code | PDF
0% found this document useful (0 votes)
15 views2 pages

CS401 Code

The document contains assembly language code that calculates the sum of a set of digits stored in an array and then subtracts each digit from that sum. It initializes registers, loops through the digits to compute the sum, and subsequently performs the subtraction, storing the results in another array. Finally, the program terminates gracefully.

Uploaded by

ibtisamali235
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)
15 views2 pages

CS401 Code

The document contains assembly language code that calculates the sum of a set of digits stored in an array and then subtracts each digit from that sum. It initializes registers, loops through the digits to compute the sum, and subsequently performs the subtraction, storing the results in another array. Finally, the program terminates gracefully.

Uploaded by

ibtisamali235
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/ 2

ID ( BC230200919 )

Assembly Language Code:


.model small
.data
vuid db 2,3,0,2,0,0,9,1,9 ; Your VUID digits stored in array
sum db 0 ; To store sum of digits
result db 9 dup(?) ; To store result after subtraction

.code
mov ax, @data
mov ds, ax

; Initialize registers
xor cx, cx ; Counter
mov cl, 9 ; 9 digits
xor si, si ; Index for VUID array
xor al, al ; Clear AL for sum

; Calculate sum of digits


sum_loop:
add al, [vuid+si]
inc si
loop sum_loop

mov sum, al ; Store the sum

; Subtract each digit from the sum


mov cl, 9 ; Reset counter
xor si, si ; Reset index
xor di, di ; Index for result array
mov ah, 0 ; Clear AH for subtraction

sub_loop:
mov al, sum ; Load sum
sub al, [vuid+si] ; Subtract digit
mov [result+di], al ; Store result
inc si
inc di
loop sub_loop

; Terminate program
mov ah, 4Ch
int 21h
end

You might also like