Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; calculation of a+b-c
- .MODEL SMALL ; IN THIS COURSE ALL MODEL ARE SMALL
- .STACK 100H ; WE ALWAYS USE STACK 100H
- .DATA ; DATA SEGMENT
- SN_N1 DB "Enter first number: $" ; we store the string here
- SN_N2 DB 0DH,0AH,"Enter second number: $" ; we store the string here
- SN_N3 DB 0DH,0AH,"Enter third number: $" ; we store the string here
- SN_STR1 DB 0AH,0DH,'CALCULATION OF ' ; PRINT A NEW LINE AFTER TAKING INPUT SO WE USE 0AH,0DH
- SN_FIRSTNUM DB ? ; TAKE A VARIABLE WHERE WE TAKE FIRST NUMBER
- SN_STR DB "," ; GIVE A COMMA (,) HERE
- SN_SECONDNUM DB ? ; TAKE A VARIABLE WHERE WE TAKE SECOND NUMBER
- SN_STR2 DB ' AND ' ; ASSIGN A STRING IN STR 2
- SN_THIRDNUM DB ? ; TAKING THIRD NUMBER
- SN_STR3 DB ' IS ' ; ASSIGN ANOTHER STRING IN STR3
- SN_ANS DB ? ; TAKE A VARIABLE WHERE WE WILL PUT OUT SUMMATION, AND DO NOT END THE STRING BY $ SIGN
- SN_STR4 DB ' $' ; ASSIGN $ HERE SO ALL AVOBE STRING ARE PRINT TOGETHER
- .CODE
- MAIN PROC ; MAIN CODE START HERE
- ;PROGRAMME SEGMENT PREFIX
- MOV AX,@DATA
- MOV DS,AX ; INITILATION OF DS
- MOV AH,9 ; TO PRINT STRING WE USE IT
- LEA DX,SN_N1 ; LOADED THE STRING LEA = LOAD EFFICTIVE ADDRESS
- INT 21H ; THIS WILL PRINT THE LINE
- MOV AH,1 ; TAKING SOME INPUT
- INT 21H ; INTRUPT THE WORK
- MOV BL,AL ; IF WE TAKE INPUT GENERALY GOES TO AL SO WE MOVE THE INPUT VALUE INTO BL
- MOV SN_FIRSTNUM,AL ; MOVE TO FIRSTNUMBER
- MOV AH,9 ; TO PRINT STRING WE USE IT
- LEA DX,SN_N2 ; LOADED THE STRING
- INT 21H ; THIS WILL PRINT THE LINE
- MOV AH,1 ; TAKING SOME INPUT
- INT 21H ; INTRUPT THE WORK
- MOV CL,AL ; IF WE TAKE INPUT GENERALY GOES TO AL SO WE MOVE THE INPUT VALUE INTO BL
- MOV SN_SECONDNUM,AL ; MOVE TO SECOND NUMBER
- MOV AH,9 ; TO PRINT STRING WE USE IT
- LEA DX,SN_N2 ; LOADED THE STRING
- INT 21H ; THIS WILL PRINT THE LINE
- MOV AH,1 ; TO TAKE INPUT
- INT 21H ; TAKE THIRD NUMBER HERE
- MOV SN_THIRDNUM,AL ; MOVE THIRD NUMBER TO THIRDNUM VARIABLE
- ADD BL,CL ; ADD FIRST TWO NUMBER HERE
- SUB BL,30H ; CONVERT IT FROM ASCII TO INTEGER
- SUB BL,AL ; HERE WE SUBTRACT BL AND AL
- ADD BL,30H ; TO COVERT ASCII TO DECIMAL WE ADDED 30 FROM SUBTRACT VALUE BL + 30 = BL , NOW IT IS DECIMAL.. CHECK ASCII TO UNDERSTAND BETTER
- MOV SN_ANS,BL ; NOW MOVE THE VALUE INTO ANSWER
- MOV AH,9 ; PRINT STRING
- LEA DX,SN_STR1 ; VARIABLE PRINTING FIRST TO LAST BECAUSE WE USE $ AT LAST. SO IT PRINT FIRST TO LAST
- INT 21H ; INTRUPT THE WORK
- MOV AX,4CH ; TERMINATED THE CODE AND EXIT
- INT 21H
- MAIN ENDP
- END MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement