Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'EMU8086.INC'
- .model small
- .stack 100h
- .data
- ; Initialize the data sagement variable
- N DW ?
- M DW ?
- i DW ?
- SUM DW ?
- .code
- main proc
- ; Initialize the data sagement
- MOV AX,@DATA
- MOV DS,AX
- ; Input block
- INPUT:
- MOV N,0
- MOV i,1
- MOV SUM,0
- MOV M,10
- print "Enter an number: "
- MOV AH,1
- ; Continuously take input until user press enter
- WHILE:
- INT 21H
- CMP AL,0DH
- JE INVALID
- SUB AL,48
- MOV BL,AL
- MOV AX,N
- IMUL M
- MOV DX,AX
- MOV AL,BL
- AND AX,000FH
- ADD DX,AX
- MOV N,DX
- MOV AH,1
- JMP WHILE
- ; After press enter check is input number is greater then 0 or not
- ; if greater then 0 then go to the calculation block otherwise go to the end of the program block
- INVALID:
- CMP N,0
- JGE CALC
- JMP ENDJ
- CALC:
- MOV AX,N
- printn ""
- MODARATE_CONDITION:
- cmp N, 50 ; Compare with 50
- jl END_IF ; Because there is no condition for less than 50 on assignment so we jump to the end if
- jge MODARATE_REGULAR_CONDITION ; If grade is greater or equal compre to 50 then jump to the modarate section to check with 100
- MODARATE_REGULAR_CONDITION:
- cmp N, 100 ; Compare with 100
- jl OUTPUT_MODARATE ; If grade is less then 100 then jump to the modarate output
- jge REGULAR_HEAVY_CONDITION ; If grade is grater or equal compare to 100 then jump to the regular heavy section to check with 150
- REGULAR_HEAVY_CONDITION:
- cmp N, 150
- jl OUTPUT_REGULAR ; If grade is less then 150 then jump to the regular output
- jge HEAVY_INDUSTRY_CONDITION ; If grade is grater or equal compare to 150 then jump to the heavy industry section to check with 200
- HEAVY_INDUSTRY_CONDITION:
- cmp N, 200
- jl OUTPUT_HEAVY ; If grade is less then 200 then jump to the heavy output
- jge OUTPUT_INDUSTRY ; If grade is grater or equal compare to 200 then jump to the heavy output
- ; Show modarate Output
- OUTPUT_MODARATE:
- printn "Modarate"
- jmp END_IF
- ; Show regular Output
- OUTPUT_REGULAR:
- printn "Regular"
- jmp END_IF
- ; Show Heavy Output
- OUTPUT_HEAVY:
- printn "Heavy"
- jmp END_IF
- ; Show Industry Output
- OUTPUT_INDUSTRY:
- printn "Industry"
- jmp END_IF
- ; Shutdown the executation block from if condition
- END_IF:
- mov ax,4ch
- int 21h
- ; End of the program
- ENDJ:
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement