3. roject description
Assembly program to convert Centigrade
(Celsius) to Fahrenheit temperature
measuring scales
.Temperature in Celsius is always between 0 ‘C -
99 ‘C, Hence the program will take two digit
decimal number as INPUT. Let me tell you
Formula of Conversion .
Celsius = (Fahrenheit – 32)* 5 / 9.
Fahrenheit = (Celsius * 9 / 5) + 32. -this is
what we are IMPLIMENTING.
4. planation :
In this Assembly Language Programming, A
single program is divided into four Segments
which are 1. Data Segment, 2. Code Segment,
3. Stack Segment, and 4. Extra Segment.
The identified variables are T, RES,
MSG1 and MSG2.
5. Purpose:
conversion of temperature from C to F scale
implement the concept of LOOPS JUMPS
conversion from ASCII to BCD And BCD to ASCII
MULTIPICATION and DIVISION and in this
project we implementThe concept of logical
operations
compare instruction and register to register data
transfer
6. DATA SEGMENT ;starting of data segment
T DB ?
RES DB 10 DUP ('$')
MSG1 DB "ENTER TEMPERATURE IN CELSIUS (ONLY IN 2 DIGITS) : $"
MSG2 DB 10,13,"CONVERTED IS FAHRENHEIT (TEMPERATURE) : $"
DATA ENDS ; end of data segment
CODE SEGMENT
ASSUME DS:DATA,CS ; assuming data for data and code for code segment
.CODE START: ; label for starting code
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1 ;displaying message 1
MOV AH,9 ; use to print the message of address in DX
INT 21H
MOV AH,1 ; read a character
INT 21H ; linking with dos
SUB AL,30H ; conversion
MOV AH,0 ;clear unwanted value
MOV BL,10 ; transfer 10 to BL
MUL BL ;BL result will multiply with al
MOV BL,AL ; transfer result to BL
MOV AH,1 ; read a character
INT 21H
SUB AL,30H ; conversion to BCD
MOV AH,0 ; clear unwanted value
ADD AL,BL ;addition
MOV T,AL ; AL value to the variable t for temperature
7. MOV DL,9 ; copying 9 to dl register
MUL DL ;9 multiply with AL give(c*9)
MOV BL,5 ; copying 5 value to BL
DIV BL ; DIVISION OF BL with ax gives (9*C)/5
MOV AH,0 ; clear unwanted value
ADD AL,32 ; add 32 to BL… GIVES (9*C)/5+ 32
LEA SI,RES ; use to load effective address to SI
CALL HEX2DEC ; call for procedure
LEA DX,MSG2 ; display MSG 2
MOV AH,9 ;print string MSG
INT 21H
LEA DX,RES ; print the string or message
MOV AH,9
INT 21H
MOV AH,4CH ; exit to dos or OS
INT 21H
CODE ENDS ;end of code segment
HEX2DEC PROC NEAR ; near procedure is called
MOV CX,0 ; clear unwanted value
MOV BX,10 ; COPYING 10 to BX
LOOP1: MOV DX,0 ; START OF LOOP and removing garbage value from DX
DIV BX ;divide BX with AX
ADD DL,30H ; conversion to ASCII
PUSH DX ; STORE 16 BIT DATA TO DX
INC CX ; INCREMENT VALUE OF CX
CMP AX,9 ; COMPARE AX WITH 9
JG LOOP1 IF GREATER THEN JUMP TO LOOP 1
8. ADD AL,30H ; CONVERSION TO ASCII
MOV[SI],AL ;SAVING CHARACTER IN CHARACTER
array
LOOP2: POP AX ;get 16 bit data from AX
INC SI ;increment the SI
MOV [SI],AL ; SAVING CHARACTER TO CHAR ARRAY
LOOP LOOP2 ; END OF LOOP
RET ; RETURN INSTRUCTION
HEX2DEC ENDP ;END OF PROCEDURE
END START ; ENDING POINT OF CODE
10. Summary:
This project is based on basic assembly
operations division multiplication jumps
loops procedures stack etc are used . It
act as temperature converter and
display temperature in another scale