hello,
can somebody expert help me to check this program? I already write this program which is for my college mini project.
This program is to show student exam result but the looping is not function correctly. it will give output same if i put > then 3 student.
please help..tq
TITLE CalcMark       (calculate.asm)
INCLUDE Irvine32.inc
.data
fileName BYTE 80 DUP (0)
fileName1 BYTE 80 DUP (0)
fileName2 BYTE 80 DUP (0)
input1Â Â BYTE ?
Prompt  BYTE "        SISTEM PENGIRAAN MARKAH PELAJAR OKBH DCS 2103",0
Promptx BYTE "    --------------********************************----------------",0
Prompt1Â BYTEÂ "KEPUTUSAN MARKAH PELAJARÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ",0
Prompt2 BYTE "Nurul Nadiah : ",0
Prompt3Â BYTEÂ "Syazrul Arman : ",0
Prompt4 BYTE "Nurul Nashwa : ",0
PromptEÂ BYTEÂ "Â Â Â Â Â Â Â Â --------------------FINISH-------------------",0
PromptA BYTE "Lecturer's Name  : SITI HAJAR OTHMAN           ",0
PromptA1 BYTE "Section      : 02                  ",0
PromptA2 BYTE "Semester      : 1 2007/2008              ",0
PromptA3 BYTE "Number of Student : ",0
PromptA4 BYTE "Number of Student : 3                   ",0
PromptBÂ BYTEÂ "Student 1Â Â Â Â Â : ",0
PromptB1 BYTEÂ "Quiz [15]Â Â Â Â Â : ",0
PromptB2 BYTEÂ "Assignment [10]Â Â : ",0
PromptB3 BYTEÂ "Mid Term Exam [30] : ",0
PromptB4 BYTEÂ "Final Exam [45]Â Â : ",0
PromptCÂ BYTEÂ "Student 2Â Â Â Â Â : ",0
PromptC1 BYTEÂ "Quiz [15]Â Â Â Â Â : ",0
PromptC2 BYTEÂ "Assignment [10]Â Â : ",0
PromptC3 BYTEÂ "Mid Term Exam [30] : ",0
PromptC4 BYTEÂ "Final Exam [45]Â Â : ",0
PromptDÂ BYTEÂ "Student 3Â Â Â Â Â : ",0
PromptD1 BYTEÂ "Quiz [15]Â Â Â Â Â : ",0
PromptD2 BYTEÂ "Assignment [10]Â Â : ",0
PromptD3 BYTEÂ "Mid Term Exam [30] : ",0
PromptD4 BYTEÂ "Final Exam [45]Â Â : ",0
PromptFÂ BYTEÂ "Â :Â ",0
PromptGAÂ BYTEÂ "Grade A",0
PromptGA1 BYTEÂ "Grade A-",0
PromptGBÂ BYTEÂ "Grade B+",0
PromptGB1 BYTEÂ "Grade B",0
PromptGB2 BYTEÂ "Grade B-",0
PromptGCÂ BYTEÂ "Grade C+",0
PromptGC1 BYTEÂ "Grade C",0
PromptGC2 BYTEÂ "Grade C-",0
PromptGDÂ BYTEÂ "Grade D+",0
PromptGD1 BYTEÂ "Grade D",0
PromptGEÂ BYTEÂ "Grade E",0
aName  QWORD ?
nameSize = ($ - aName)
WÂ Â Â Â DWORD ?
XÂ Â Â Â DWORD ?
YÂ Â Â Â DWORD ?
ZÂ Â Â Â DWORD ?
pelajar1 DWORD ?
pelajar2 DWORD ?
pelajar3 DWORD ?
.code
main PROC
;skrin utama----------------------------------------------------------------------------------
   mov edx,OFFSET Prompt ; display HEADER
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET Promptx ; display HEADER LINE
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA1 ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA2 ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA3 ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov input1,al
call crlf
   call crlf
   call crlf
;pelajar 1 =================================================================
   mov edx,OFFSET PromptB ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadString
   mov edx,OFFSET PromptB1 ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov W,eax
   mov edx,OFFSET PromptB2  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov X,eax
   mov edx,OFFSET PromptB3  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Y,eax
   mov edx,OFFSET PromptB4  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Z,eax
   call sum_rtn
mov pelajar1,eax
call crlf
call crlf
;pelajar 2 =================================================================
   mov edx,OFFSET PromptC ; display a prompt
call WriteString
mov edx,OFFSET fileName1
mov ecx,SIZEOF fileName1 - 1
call ReadString
   mov edx,OFFSET PromptC1 ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov W,eax
   mov edx,OFFSET PromptC2  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov X,eax
   mov edx,OFFSET PromptC3  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Y,eax
   mov edx,OFFSET PromptC4  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Z,eax
   call sum_rtn
mov pelajar2,eax
call crlf
   call crlf
;pelajar 3 =================================================================
   mov edx,OFFSET PromptD ; display a prompt
call WriteString
mov edx,OFFSET fileName2
mov ecx,SIZEOF fileName2 - 1
call ReadString
   mov edx,OFFSET PromptD1 ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov W,eax
   mov edx,OFFSET PromptD2  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov X,eax
   mov edx,OFFSET PromptD3  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Y,eax
   mov edx,OFFSET PromptD4  ; display a prompt
call WriteString
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName - 1
call ReadInt
mov Z,eax
call sum_rtn
mov pelajar3,eax
call crlf
   call clrscr
;skrin output =================================================================
   call crlf
   call crlf
   mov edx,OFFSET Prompt ; display a prompt
call WriteString
   call crlf
   call crlf
   call crlf
   mov edx,OFFSET Promptx ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA1 ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA2 ; display a prompt
call WriteString
   call crlf
   call crlf
   mov edx,OFFSET PromptA4 ; display a prompt
call WriteString
call crlf
   call crlf
   call crlf
;markah peratusan pelajar =================================================================
   mov edx,OFFSET Prompt1 ; display a prompt
call WriteString
   call crlf
   call crlf
   call crlf
;pelajar 1
   mov edx,OFFSET fileName
   call writeString
   mov edx,OFFSET PromptF
   call writeString
   mov eax,pelajar1
call writeDec
   call crlf
   call grade
;pelajar 2
   mov edx,OFFSET fileName1
   call writeString
   mov edx,OFFSET PromptF
   call writeString
   mov eax,pelajar2
call writeDec
   call crlf
   call grade
;pelajar 3
   mov edx,OFFSET fileName2
   call writeString
   mov edx,OFFSET PromptF
   call writeString
   mov eax,pelajar3
call writeDec
   call crlf
   call grade
   call crlf
   call crlf
   mov edx,OFFSET PromptE ; display FINISH
call WriteString
   call crlf
   call crlf
   exit
;calculate marks individually =================================================================
sum_rtn PROC
   mov eax,W
mov ebx,X
mov edx,Y
mov ecx,Z
add eax,ebx
add eax,edx
add eax,ecx
call writeDec
   ret
;grade Proc =================================================================
grade PROC
   cmp eax,85        ; eax >= 85 && eax =< 100
   jnae L2          ;
   cmp eax,100
   jnle L2          ;
   mov edx,OFFSET PromptGA  ; GRADE A
   call writeString
   call crlf
   call crlf
   ret
L1:
   cmp eax,80        ; eax >= 80 && eax =< 84
   jnae L2
   cmp eax,84
   jnle L2
   mov edx,OFFSET PromptGA1    ; GRADE A-
   call writeString
   call crlf
   call crlf
   ret
L2:
   cmp eax,75        ; eax >= 75 && eax =< 79
   jnae L3
   cmp eax,79
   jnle L3
   mov edx,OFFSET PromptGB    ; GRADE B+
   call writeString
   call crlf
   call crlf
   ret
L3:
   cmp eax,70        ; eax >= 70 && eax =< 74
   jnae L4
   cmp eax,74
   jnle L4
   mov edx,OFFSET PromptGB1    ; GRADE B
   call writeString
   call crlf
   call crlf
   ret
L4:
   cmp eax,65        ; eax >= 65 && eax =< 69
   jnae L5
   cmp eax,69
   jnle L5
   mov edx,OFFSET PromptGB2     ; GRADE B-
   call writeString
   call crlf
   call crlf
   ret
L5:
   cmp eax,60        ; eax >= 60 && eax =< 64
   jnae L6
   cmp eax,64
   jnle L6
   mov edx,OFFSET PromptGC     ; GRADE C+
   call writeString
   call crlf
   call crlf
   ret
L6:
   cmp eax,55        ; eax >= 55 && eax =< 59
   jnae L7
   cmp eax,59
   jnle L7
   mov edx,OFFSET PromptGC1    ; GRADE C
   call writeString
   call crlf
   call crlf
   ret
L7:
   cmp eax,50        ; eax >= 50 && eax =< 54
   jnae L8
   cmp eax,54
   jnle L8
   mov edx,OFFSET PromptGC2     ; GRADE C-
   call writeString
   call crlf
   call crlf
   ret
L8:
   cmp eax,45        ; eax >= 45 && eax =< 49
   jnae L9
   cmp eax,49
   jnle L9
   mov edx,OFFSET PromptGD     ; GRADE D+
   call writeString
   call crlf
   call crlf
   ret
L9:
   cmp eax,40        ; eax >= 40 && eax =< 44
   jnae L10
   cmp eax,44
   jnle L10
   mov edx,OFFSET PromptGD1    ; GRADE D
   call writeString
   call crlf
   call crlf
   ret
L10:
   cmp eax,0        ; eax >= 0 && eax =< 39
   jl  quit
   cmp eax,39
   jnle quit
   mov edx,OFFSET PromptGE     ; GRADE E
   call writeString
   call crlf
   call crlf
   ret
quit:
exit
grade ENDP
sum_rtn ENDP
main ENDP
END main
As far as I can tell, without knowing what you intended it to do, your code runs correctly, and after commenting the “exit� on line 324 it runs to the end. I cannot find any loop structure in the code. A loop repeats a section of code until a termination condition is reached. An example would be if you used a single block of code to replace the code labeled pelajar 1, pelajar 2, and pelajar 3, and looped the block 3 times, each with a different student number (as far as I can tell everything else is the same).
Also, I can’t see any good reason to nest the procedures as you have. The ENDP directive should be at the end of the procedure’s code, before the start of the next procedure.
Also, in your sum_rtn code, this:
  mov eax,W
  mov ebx,X
  mov edx,Y
  mov ecx,Z
  add eax,ebx
  add eax,edx
  add eax,ecx
Could be replaced with this:
  mov eax,W
  add eax,X
  add eax,Y
  add eax,Z
You'll need to loop for each student, instead of just copying the same code 3 times (for only 3 students - not more, not less.)
With the loop, then you can then have 1 student, or 5 students, or 100 students. And your code will be three times smaller :wink
So, something like...
print Header + Course Details
input number of students (=> numStudents)
n = 1
input_loop:
print "Student ", 'n'
input student name (=> name)
print "Quiz [15]"
input quiz grade (=> W)
print "Assignment [10]"
input grade (=> X)
print "Mid Term Exam [30]"
input grade (=> Y)
print "Final Exam [45]"
input grade (=> Z)
sum grades (=> grade)
inc n
n <= numStudents ? jle input_loop
clear screen
print Header + Course Details
print "Number of Students : ", 'numStudents'
n = 1
output_loop:
print 'name', " : ", 'grade'
inc n
n <= numStudents ? jle outut_loop
exit
When you've fixed that and the loops work, you should notice that the 'name' and 'grade' of each student are lost with each loop..
Fix the loops first, then learn about arrays, then come back we can talk :wink
ok I will try to fix it 1st.. tq for the tips.
for the loop as you shown below is using C# rite? can I only using asembly language for looping? because as what as i concern, I can't use C# for this project. must use purely assembly language.
Tq
I only described what you need to do, but not in any specific language (not C# or any other, but closest to assembly.) If you must write the project in pure asm, then that's what you must use :P
To loop you will need to "cmp" and then use a conditional jump (in a similar way to how the grade proc does.)
Understand what you need to do, how it works, then write the asm code to make it do that.