Student Id
Student Id
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
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