Advertisement
tareqmahmud9

Grade System

Dec 8th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include 'EMU8086.INC'
  2. .model small
  3. .stack 100h
  4. .data
  5. ; Initialize the data sagement variable
  6. N DW ?
  7. M DW ?
  8. i DW ?
  9. SUM DW ?
  10.  
  11. .code
  12.  
  13. main proc
  14.     ; Initialize the data sagement
  15.     MOV AX,@DATA
  16.     MOV DS,AX
  17.    
  18.     ; Input block  
  19.     INPUT:
  20.         MOV N,0
  21.         MOV i,1
  22.         MOV SUM,0
  23.         MOV M,10
  24.         print "Enter an number: "
  25.         MOV AH,1
  26.    
  27.     ; Continuously take input until user press enter
  28.     WHILE:
  29.         INT 21H
  30.         CMP AL,0DH
  31.         JE INVALID
  32.         SUB AL,48
  33.         MOV BL,AL
  34.         MOV AX,N
  35.         IMUL M
  36.         MOV DX,AX
  37.         MOV AL,BL
  38.         AND AX,000FH  
  39.         ADD DX,AX
  40.         MOV N,DX
  41.         MOV AH,1
  42.         JMP WHILE
  43.    
  44.     ; After press enter check is input number is greater then 0 or not
  45.     ; if greater then 0 then go to the calculation block otherwise go to the end of the program block    
  46.     INVALID:
  47.         CMP N,0
  48.         JGE CALC
  49.         JMP ENDJ
  50.    
  51. CALC:
  52.    
  53.     MOV AX,N
  54.     printn ""
  55.    
  56.     MODARATE_CONDITION:
  57.         cmp N, 50  ; Compare with 50
  58.         jl END_IF   ; Because there is no condition for less than 50 on assignment so we jump to the end if
  59.         jge MODARATE_REGULAR_CONDITION   ; If grade is greater or equal compre to 50 then jump to the modarate section to check with 100
  60.    
  61.     MODARATE_REGULAR_CONDITION:
  62.         cmp N, 100 ; Compare with 100
  63.         jl  OUTPUT_MODARATE ; If grade is less then 100 then jump to the modarate output
  64.         jge REGULAR_HEAVY_CONDITION  ; If grade is grater or equal compare to 100 then jump to the regular heavy section to check with 150
  65.    
  66.     REGULAR_HEAVY_CONDITION:
  67.         cmp N, 150
  68.         jl  OUTPUT_REGULAR ; If grade is less then 150 then jump to the regular output
  69.         jge HEAVY_INDUSTRY_CONDITION   ; If grade is grater or equal compare to 150 then jump to the heavy industry section to check with 200
  70.    
  71.     HEAVY_INDUSTRY_CONDITION:
  72.         cmp N, 200
  73.         jl  OUTPUT_HEAVY   ; If grade is less then 200 then jump to the heavy output
  74.         jge OUTPUT_INDUSTRY ; If grade is grater or equal compare to 200 then jump to the heavy output
  75.        
  76.    
  77.     ; Show modarate Output
  78.     OUTPUT_MODARATE:
  79.         printn "Modarate"
  80.         jmp END_IF
  81.    
  82.     ; Show regular Output
  83.     OUTPUT_REGULAR:
  84.         printn "Regular"
  85.         jmp END_IF
  86.    
  87.     ; Show Heavy Output    
  88.     OUTPUT_HEAVY:
  89.         printn "Heavy"
  90.         jmp END_IF
  91.    
  92.     ; Show Industry Output    
  93.     OUTPUT_INDUSTRY:
  94.         printn "Industry"
  95.         jmp END_IF
  96.    
  97.    
  98.     ; Shutdown the executation block from if condition
  99.     END_IF:
  100.         mov ax,4ch
  101.         int 21h
  102.  
  103. ; End of the program
  104. ENDJ:
  105. main endp
  106. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement