0% found this document useful (0 votes)
9 views2 pages

Student Id

Uploaded by

arshman372
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)
9 views2 pages

Student Id

Uploaded by

arshman372
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

STUDENT ID: BC230217539

[org 0x0100] ; Program starting address for .COM files

jmp start ; Jump to start of program

student_id db 1,9,0,2,0,0,4,0,9 ; Student ID digits


id_length equ 9 ; The number of digits in student ID
sum_result dw 0 ; To store the sum result (word size)

start:
xor ax, ax ; Clear AX register (will store sum in AL)
mov si, 0 ; Initialize SI (index) to 0

calculate_sum:
mov al, [student_id + si] ; Load the current digit into AL
add ah, al ; Add the digit to AH (accumulating sum in AH)
inc si ; Move to the next digit
cmp si, id_length ; Compare the index (SI) with the length of the student ID
jl calculate_sum ; If SI < id_length, keep looping

mov [sum_result], ah ; Store the sum in sum_result (AX holds the sum)

test ah, 1 ; Test the least significant bit (LSB) of AH (check even/odd)
jz even ; If LSB is 0 (even), jump to "even" label

mov dx, 0 ; If odd, store 0 in DX


jmp done ; Jump to done label

even:
mov dx, 1 ; If even, store 1 in DX

done:
mov ax, 4C00h ; DOS interrupt to terminate the program
int 21h ; Terminate the program and return to DOS
Screenshot

You might also like