Assembly language

You have this code posted as an answer to one of your questions already, but I want to know how would you write this code without conditional control flow ; directives like .ELSE, .ELSE IF? I am having a hard time figuring it out.


str1 BYTE “Enter an integer score: “,0

str2 BYTE “The letter grade is: “,0


main PROC

call Clrscr

mov edx,OFFSET str1 ; input score from user

call WriteString

call ReadInt

call Crlf

.IF eax >= 90 ; multiway selection structure to

mov al,’A’ ; choose the correct grade letter

.ELSEIF eax >= 80

mov al,’B’

.ELSEIF eax >= 70

mov al,’C’

.ELSEIF eax >= 60

mov al,’D’


mov al,’F’


mov edx,OFFSET str2

call WriteString

call WriteChar ; display grade letter in AL

call Crlf


main ENDP

END main


You can replace the conditional directives with the following sequence

   test eax, 90
   jb elseif1
   mov al,’A’
   jmp endif

   test eax,80
   jb elseif2
   mov al,’B’
   jmp endif

   jb elseif3
   mov al, ‘C’
   jmp endif

   test eax, 60
   jb else
   mov al, ‘D’
   jmp endin

   mov al, ‘F’