ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Write a ALP program that will compute a grade for this class based on grades input into it. Write two
different procedures one for computing total marks based of different examinations held and another
for computing overall grade of student.
Procedures-I: The total marks will be computed as follows:
20% Midterm Exam
20% Final Project
30% Quizzes
30% Projects
Procedure-II: The letter grade will be computed from the overall grade as
follows:
93+: A
90+: A-
87+: B+
83+: B
80+: B-
77+: C+
73+: C
70+: C-
65+: D
0+: F
.model small
.data
mid db 10,13,'Midterm Exam Marks(0-20): $'
prj db 10,13,'Final Project Marks(0-20): $'
quz db 10,13,'Quizzes Marks(0-30): $'
pjs db 10,13,'Projects Marks(0-30): $'
grd db 10,13,'Grade :$'
.code
mov ax, @data
mov ds, ax
call totm
call grad
mov ah, 4ch
int 21h
proc totm
mov ah, 9
lea dx, mid
int 21h
call readno
cmp al, 20h
ja totm
mov ch,al
rdprj:
mov ah, 9
lea dx, prj
int 21h
call readno
cmp al, 20h
ja rdprj
add ch,al
rdqz:
mov ah, 9
lea dx, quz
int 21h
call readno
cmp al, 30h
ja rdqz
add ch,al
rdpjs:
mov ah, 9
lea dx, pjs
int 21h
call readno
cmp al, 30h
ja rdpjs
add ch,al
ret
endp totm
proc grad
mov ah, 9
lea dx, grd
int 21h
mov dh, ' '
mov dl, 'A'
cmp ch, 93h
jae dspg
mov dh, '-'
mov dl, 'A'
cmp ch, 90h
jae dspg
mov dh, '+'
mov dl, 'B'
cmp ch, 87h
jae dspg
mov dh, ' '
mov dl, 'B'
cmp ch, 83h
jae dspg
mov dh, '-'
mov dl, 'B'
cmp ch, 80h
jae dspg
mov dh, '+'
mov dl, 'C'
cmp ch, 77h
jae dspg
mov dh, ' '
mov dl, 'C'
cmp ch, 73h
jae dspg
mov dh, '-'
mov dl, 'C'
cmp ch, 70h
jae dspg
mov dh, ' '
mov dl, 'D'
cmp ch, 65h
jae dspg
mov dl, 'F'
dspg:
mov ah,2
int 21h
mov dl, dh
int 21h
ret
endp grad
proc readno
mov ah, 1
int 21h
cmp al, '0'
jb readno
cmp al, '9'
ja readno
mov bl, al
and bl, 0fh
dgt2:
mov ah, 1
int 21h
cmp al, 13
je xitrd
cmp al, '0'
jb dgt2
cmp al, '9'
ja dgt2
mov cl, 4
shl bl, cl
and al, 0fh
or bl, al
xitrd:
mov al,bl
ret
endp readno
end

More Related Content

Session 9 1 alp to compute a grade using procedures

  • 1. Write a ALP program that will compute a grade for this class based on grades input into it. Write two different procedures one for computing total marks based of different examinations held and another for computing overall grade of student. Procedures-I: The total marks will be computed as follows: 20% Midterm Exam 20% Final Project 30% Quizzes 30% Projects Procedure-II: The letter grade will be computed from the overall grade as follows: 93+: A 90+: A- 87+: B+ 83+: B 80+: B- 77+: C+ 73+: C 70+: C- 65+: D 0+: F .model small .data mid db 10,13,'Midterm Exam Marks(0-20): $' prj db 10,13,'Final Project Marks(0-20): $' quz db 10,13,'Quizzes Marks(0-30): $' pjs db 10,13,'Projects Marks(0-30): $' grd db 10,13,'Grade :$' .code mov ax, @data mov ds, ax call totm call grad mov ah, 4ch int 21h proc totm mov ah, 9 lea dx, mid int 21h call readno cmp al, 20h ja totm mov ch,al rdprj: mov ah, 9 lea dx, prj int 21h call readno cmp al, 20h ja rdprj add ch,al rdqz:
  • 2. mov ah, 9 lea dx, quz int 21h call readno cmp al, 30h ja rdqz add ch,al rdpjs: mov ah, 9 lea dx, pjs int 21h call readno cmp al, 30h ja rdpjs add ch,al ret endp totm proc grad mov ah, 9 lea dx, grd int 21h mov dh, ' ' mov dl, 'A' cmp ch, 93h jae dspg mov dh, '-' mov dl, 'A' cmp ch, 90h jae dspg mov dh, '+' mov dl, 'B' cmp ch, 87h jae dspg mov dh, ' ' mov dl, 'B' cmp ch, 83h jae dspg mov dh, '-' mov dl, 'B' cmp ch, 80h jae dspg mov dh, '+' mov dl, 'C' cmp ch, 77h jae dspg mov dh, ' ' mov dl, 'C' cmp ch, 73h jae dspg mov dh, '-' mov dl, 'C'
  • 3. cmp ch, 70h jae dspg mov dh, ' ' mov dl, 'D' cmp ch, 65h jae dspg mov dl, 'F' dspg: mov ah,2 int 21h mov dl, dh int 21h ret endp grad proc readno mov ah, 1 int 21h cmp al, '0' jb readno cmp al, '9' ja readno mov bl, al and bl, 0fh dgt2: mov ah, 1 int 21h cmp al, 13 je xitrd cmp al, '0' jb dgt2 cmp al, '9' ja dgt2 mov cl, 4 shl bl, cl and al, 0fh or bl, al xitrd: mov al,bl ret endp readno end