0% found this document useful (0 votes)
66 views

Assignment 2 Solution File cs401

This document contains assembly language code that displays a student's name, ID, CGPA, and course code. It then stores digit values for the student's ID in an array and calculates the sum of those digits. Finally, it displays a message and prints out the summed ID value.

Uploaded by

fecem12298
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Assignment 2 Solution File cs401

This document contains assembly language code that displays a student's name, ID, CGPA, and course code. It then stores digit values for the student's ID in an array and calculates the sum of those digits. Finally, it displays a message and prints out the summed ID value.

Uploaded by

fecem12298
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

[org 0x0100]

jmp start

MSG1 db '$'

Na db 'Your name$' <--(write in your name)

Id db 'Your id$' <--(write in your vuid)

Cgpa db 'your cgpa$' <--(write in your cgpa)

Co_Code db 'cs401$'

MSG2 db 'Sum of vu id:$'

id_arr: dw 1,2,3,4,5,6,7,8,9 <--(write in your vuid digit)

sum: dw 0

clrscr:

mov ah, 06h

mov al, 0

mov bh, 07h

mov cx, 00

mov dh, 24

mov dl, 79

int 10h

ret

sum_id:

mov bx, 0

mov cx, 9

mov ax, 0

sum_loop:

add ax, [id_arr + bx]


add bx, 2

loop sum_loop

mov [sum], ax

mov ax, [sum]

mov cx, 10

mov bx, 10

mov di, -2

sub si, di

con_dig:

xor dx, dx

div cx

add dl, '0'

dec si

mov [si], dl

test ax, ax

jnz con_dig

mov dx, si

mov ah, 09h

int 21h

ret

sum_str: times 2 db 0

start:

call clrscr

mov ah, 02h

mov bh, 0
mov dh, 00h

mov dl, 00h

int 10h

mov dx, Na

mov ah, 09h

int 21h

mov dl, 0Ah

mov ah, 02h

int 21h

mov dx, Id

mov ah, 09h

int 21h

mov dl, 0Ah

mov ah, 02h

int 21h

mov dx, Cgpa

mov ah, 09h

int 21h

mov dl, 0Ah

mov ah, 02h

int 21h

mov dx, Co_Code

mov ah, 09h

int 21h

mov dl, 0Ah


mov ah, 02h

int 21h

mov dx, MSG2

mov ah, 09h

int 21h

call sum_id

mov dl, 0Ah

mov ah, 02h

int 21h

mov ax, 4C00h

int 21h

You might also like