0% found this document useful (0 votes)
23 views9 pages

Micro LR 2

The document is a lab report submitted by Umar Mustafa containing details of two experiments - string reversal and basic arithmetic operations. The first experiment involves writing assembly code to take a string from the user and display the original and reversed strings. The second experiment adds four numbers input by the user and displays the sum, handling numbers greater than 9 by separating into individual digits. The conclusion discusses techniques for string reversal in 16-bit segments and summarizes that arithmetic instructions perform operations like addition and subtraction using registers.

Uploaded by

Umar Mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views9 pages

Micro LR 2

The document is a lab report submitted by Umar Mustafa containing details of two experiments - string reversal and basic arithmetic operations. The first experiment involves writing assembly code to take a string from the user and display the original and reversed strings. The second experiment adds four numbers input by the user and displays the sum, handling numbers greater than 9 by separating into individual digits. The conclusion discusses techniques for string reversal in 16-bit segments and summarizes that arithmetic instructions perform operations like addition and subtraction using registers.

Uploaded by

Umar Mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

LAB REPORT 02

Computer Engineering
Oct 12, 2022

Name: Umar Mustafa


ID: 200365 UM
Class: BCE-5A

1
Air University Islamabad Submitted to: Miss Mariam Sabir
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 2

Lab Title: STRING DEFINITION AND REVERSAL AND BASIC ARITHMATIC OPERATIONS
Student Name: Umar Mustafa Reg. No: 200365
Objective:

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:


Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: Signature:

2
Home Tasks

1. Write an assembly code that takes string from user and display the
string and the reversed string on screen.

8086 Code
.model small
.stack 100h
.data
msga db 'Enter string: $'
msgb db 'String Entered: $'
msgc db 'Reversed String: $'
arr db 10 dup('$')
rev db 10 dup(?)
.code
.startup
lea dx,msga
mov ah,9h
int 21h

mov ah,10
lea dx,arr
mov arr,6
int 21h

mov dl,0ah
mov ah,2h
int 21h

3
lea dx,msgb
mov ah,9h
int 21h

lea dx,arr+2
mov ah,9h
int 21h

mov dl,0ah
mov ah,2h
int 21h

lea dx,msgc
mov ah,9h
int 21h

lea si,arr+2
mov cl,0
again:
mov dl,ds:[si]
inc si
inc cl
cmp dl,'$'
jne again

dec cl
dec si

4
dec si
lea di,rev
again1:
mov dl,ds:[si]
mov ds:[di],dl
dec si

inc di
dec cl
jnz again1
mov dl,'$'
mov ds:[di],dl

mov arr,6
lea dx,rev+1
mov ah,9
int 21h
.exit
end

Output

5
2. Add four numbers and display the result on screen, your program
should be capable of separating the two digits of sum if sum is greater
than 9, and should display both digits. (HINT: Use division). It is
necessary to add 30h to result before you display it in order to get the
ASCII equivalent of the result.

8086 Code
.model small
.stack 100h
.data
msga db 'Enter four numbers:$'
msgb db 'Result of addition: $'
a db ?
b db ?
.code
.startup
lea dx,msga
mov ah,9h
int 21h

mov ah,2
mov dl,0ah
int 21h
mov cl,0
mov bl,0
loop1:
mov ah,1h
int 21h
sub al,30h
mov dl,al
6
add bl,dl

mov ah,2
mov dl,0ah
int 21h

inc cl
cmp cl,4
jne loop1
lea dx,msgb
mov ah,9h
int 21h
cmp bl,9
jg greater
mov dl,bl
add dl,30h
mov ah,2h
int 21h
.exit
greater:
mov dl,bl
mov ax,dx
mov bl,10
div bl
mov a,al
mov b,ah

mov dl,a

7
add dl,48
mov ah,2h
int 21h

mov dl,b
add dl,48
mov ah,2h
int 21h
.exit
end

Output

8
Conclusion
 Reversing a string is the technique that reverses or changes the order of a given
string so that the last character of the string becomes the first character of the
string and so on.
 For 16-bit segments, however, the SI and the DI registers are used to point to the
source and destination, respectively.
 Arithmetic instructions are those instructions that perform the arithmetic operations
of addition, subtraction, multiplication, and division.
 Arithmetic operators expect numeric operands and produce a numeric result. They
are most frequently used in sub-expressions.

You might also like