Lab Session 5
Lab Session 5
Objective
To learn how to perform arithmetic operations using assembly language and to convert a
temperature value from Celsius to Fahrenheit.
Background
Tools Required
EMU86 (or any compatible x86 emulator)
Basic knowledge of assembly language
Instructions to Run the Program
Open EMU86.
Create a new file and copy the above assembly code into it.
Assemble the code using the EMU86 assembler.
Link the program.
Run the program and enter a temperature in Celsius when prompted.
Code Breakdown:
Data Segment Declaration (.DATA):
F DW ? Declares a word (16-bit) variable F that is uninitialized and will store the
result.
Code Segment Declaration (.CODE):
MOV AX,@DATA / MOV DS,AX: This is setting up the data segment so that the data
segment register (DS) can point to the .DATA segment for accessing variables like F.
MOV F, AX:
Store the final Fahrenheit result in the variable F.
Expected Output
Conclusion
In this lab, you learned how to convert Celsius to Fahrenheit using basic arithmetic instructions
in assembly language.
Exercise
1. Change Celsius to Kelvin: Modify the program to convert a temperature from Celsius to
Kelvin instead of Fahrenheit. The formula for conversion is: K=C+273.15K = C +
273.15K=C+273.15 (You can round 273.15 to 273 for simplicity.)
2. Add a Welcome Message: Add a welcome message at the beginning of the program to
greet the user before asking for the Celsius temperature.
3. Display Celsius Input: After the user enters the Celsius temperature, display the input
back to the user before showing the converted value.
.
LAB SESSION 5
Exercise
1. Change Celsius to Kelvin: Modify the program to convert a temperature from Celsius to
Kelvin instead of Fahrenheit. The formula for conversion is: K=C+273.15K = C +
273.15K=C+273.15 (You can round 273.15 to 273 for simplicity.)
2. Add a Welcome Message: Add a welcome message at the beginning of the program to
greet the user before asking for the Celsius temperature.
3. Display Celsius Input: After the user enters the Celsius temperature, display the input
back to the user before showing the converted value.
Source Code:
org 100h
.model small
.stack 100h
.data
N DW ?
K DW 273
.CODE
MAIN PROC
mov AH,9
int 21h
mov dx , offset EN ;for printing string
mov AH,9
int 21h
INPUT: ;LABEL
JMP INPUT
NEXT:
MOV BX ,N
Add K,BX
LEA DX,UN
mov AH,9
int 21h
L1:
inc cx
L2:
int 21h
loop L2
LEA DX,Result
mov AH,9
int 21h
L3:
inc cx
L4:
add dx,48
int 21h
loop L4
ret
Output:
DEPARTMENT OF SOFTWARE ENGINEERING
BACHELORS IN SOFTWARE ENGINEERING
Course Code: SE-209
Course Title: Computer Architecture & Logic Design
Lab Rubrics
Total
Signature