Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed

CMS ID: 50246

Lab No. 01
INTRODUCTION TO ASSEMBLY LANGUAGE AND BASIC INPUT/OUTPUT
OPERATIONS
 Objective:
To understand and analyze the operation of Emu80X86 microprocessor, Assembly language and
perform some basic input and output operations through emulator.

 Theory:
1) Assembly language:
An assembly language is a type of low-level programming language that is intended to
communicate directly with a computer's hardware. Unlike machine language, which consists
of binary and hexadecimal characters, assembly languages are designed to be readable by
humans
2) Emu80X86:
Emu8086 is a powerful, offline and free software for emulation, disassembling and
debugging of 8086 programs that is, 16 bits/DOS. It is an Integrated Development
Environment (IDE) that write a source, assemble it and link into .COM or .EXE file then trace
it in machine code and source file.
Following are the main functions of the software:
o Assembling:
An assembler is used to convert the written assembly language into machine object code.
o Linking:
A Linker is used to convert the object file to final executable file.
o Debugging:
The debugger allows the users to trace he action of the program and find the logical errors
in it.
o Executing:
In this final step the emulator runs the translated machine code and produces the desired
result.

 Procedure:
Following is the main procedure used to set-up the emulator.
1) Open the software, a new user interface window of the emulator will open, then click on the
“new” option to create a new code-editing window. Then choose the code template-form.

Figure 1: User-Interface window of the 80X86 emulator

1
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

2) Now a new window will open where you can write and edit your program code, after writing
the code, click on the “compile” option to check for any syntax or logical error. Then in the
end run the program by clicking on “run” option and observe the results.

Figure 2: The code editing window of the emulator

Figure 3: The internal register working window of Emu80X86 window

 Basic Functions and Instructions of the emulator:


i. MOV AX, BX: Moves the contents of BX to AX.
ii. ADD BX, AX: Add BX and AX and stores the result in BX.
iii. INT 21H: Calls for an interrupt and returns the controls to DOS.
iv. 01H: Takes a character input from user, store it in AL register and display it on screen.
v. 02H and 06H: Display the stored value in DL register on screen.
vi. 08H: Takes a character input from user, without displaying it on screen.
vii. 09H: Display a stored string terminated by a ‘$’ sign on the screen.

2
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

LAB TASK

 Objective: Run the following source codes, and observe the results.
 Program#1:
 Source code:
.MODEL SMALL ; defines memory to be used
.STACK 100H ; defines stack of 256 bytes
.CODE ; code segment starts
MOV AX, 2000
MOV BX, 2000H
MOV CX, 1010001B
MOV DX, -4567
MOV AH, ‘A’ ; Copies ASCII value of “A” in AH
MOV AL, ‘a’ ; Copies ASCII value of “a” in AH
MOV AH, 4CH
INT 21H ; INT 21h returns the control to DOS if AH=4CH
END

 Output Result:

Figure 4: The Result of the written program

3
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Program#2:
 Source code:
.MODEL SMALL ; defines memory to be used
.STACK 100H ; defines stack of 256 bytes
.CODE ; code segment starts
MOV DL, 32H ; Allocate 32h to DL register (hex value of 2)
MOV AH, 06H ; Allocate 06h to Ah which is use to echo (display) the content of DL
INT 21H ; Call Dos Interrupt 21
;code for new line
MOV dl, 010 ; 010 code is use fotnewline (you can check in ASCII table given in software)
MOV ah, 02h ; display the code of new line
INT 21h
MOV dl, 013 ; new line code give space so this code is use to remove that space
MOV ah, 02h
INT 21h
MOV DL, 44H ; Allocate 44h to DL register (hex value of D)
MOV AH, 02H ; Allocate 06h to Ah which is use to echo (display) the content of DL
INT 21H
;new line
MOV dl, 10
MOV ah, 02h
INT 21h
MOV dl, 13
MOV ah, 02h
INT 21h
MOV AH, 01H
INT 21H
MOV DL, AL ; Allocate value of AL to DL register
MOV AH, 02H ; Allocate 06h to Ah which is use to echo (display) the content of DL
INT 21H
MOV AH, 08H
INT 21H
ret

4
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Output Result:

Figure 5 & 6: The Result of the written program

5
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Program#3:
 Source code:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB '#$'
MSG0 DB 0DH,0AH, 'Please enter any digit','$'
MSG1 DB 0DH,0AH, 'The Entered Digit is $'
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
LEA DX, MSG0
MOV AH, 09H
INT 21H
MOV AH, 08H
INT 21H
MOV CL,AL
LEA DX, MSG
MOV AH, 09H
INT 21H
LEA DX, MSG1
MOV AH,09H
INT 21h
MOV DL,CL
MOV AH,02H
INT 21H
Ret

6
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Output Result:

Figure 7 & 8: The Result of the written program

7
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

LAB ASSIGNMENT

 Objective#1: Write an assembly language program that prompt you to enter 2 inputs, add
them and display it on the Screen. (The output can be in ASCII form).
 Program:
 Source code:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'Enter the first digit: $'
MSG0 DB 'Enter the second digit: ','$'
MSG1 DB 'The Result is: $'
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS, AX
LEA DX, MSG
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV BL, AL
MOV DL, 010
MOV AH, 02H
INT 21h
MOV DL, 013
MOV AH, 02H
INT 21h
LEA DX, MSG0
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV CL,AL
MOV DL, 010
MOV AH, 02h
INT 21h
MOV DL, 013
MOV AH, 02h
INT 21h
ADD BL, CL
LEA DX, MSG1
MOV AH, 09H
INT 21H
MOV DL, BL
MOV AH, 02H
INT 21H
ret

8
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Output Result:

Figure 9 & 10: The Result of the written program

9
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Objective#2: Write an assembly language program that prompts you to enter a password of 3
characters in length. The password should not be echoed to the screen rather it should show XXX.
The program then displays your name and ID number on the screen.
 Program:
 Source code:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'Please enter the password(note it must me of 3 characters): $'
MSG0 DB 'Your name is: Sameer Ahmed','$'
MSG1 DB 'Your CMS ID is: 50246$'
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS, AX
LEA DX, MSG
MOV AH, 09H
INT 21H
MOV AH, 08H
INT 21H
MOV AH, 06H
MOV DL, 58H
INT 21H
MOV AH, 08H
INT 21H
MOV AH, 06H
MOV DL, 58H
INT 21H
MOV AH, 08H
INT 21H
MOV AH, 06H
MOV DL, 58H
INT 21H
MOV DL, 010
MOV AH, 02H
INT 21h
MOV DL, 013
MOV AH, 02H
INT 21h
LEA DX, MSG0
MOV AH, 09H
INT 21H
MOV DL, 010
MOV AH, 02H
INT 21h
MOV DL, 013
MOV AH, 02H
INT 21h
LEA DX, MSG1
MOV AH, 09H
INT 21H

10
LAB MANUAL EMBEDDED SYSTEMS Name: Sameer Ahmed
CMS ID: 50246

 Output Result:

Figure 11 & 12: The Result of the written program

 Conclusion:
In this lab we learned what is 80X86 Emulator, assembly language, how to use them to write
a program and observed the output through the software.

11

You might also like