OBSERVATIONS
I am not writing the whole code but I
am discussing the logics which are used to execute the program properly.
TASK 1:
We have to
add 5 bytes.To understand this concept ,we have to review that a general register
in 8086 can store 16 bits means 2 bytes .So to store 5 bytes we need maximum 3
registers .
MOV AL,1H
MOV AH,2H
MOV
BL,3H
MOV BH,4H
MOV DL,5H
We can
perform addition on these registers accordingly.
ADD BL,DL
ADD BH,BL
ADD AL,BH
ADD AH,AL
TASK 2:
To add 5
bytes using memory locations,We first have to define bytes in the data segment
.DATA
section
DATA1 DB 1H
We will
perform same task for other 4 bytes as well.
.CODE
section
MOV AL,DATA1
MOV AH, DATA2
MOV
BL, DATA3
MOV BH, DATA4
MOV DL, DATA5
We can
perform addition on these registers accordingly.
ADD BL,DL
ADD BH,BL
ADD AL,BH
ADD AH,AL
TASK 3:
.DATA
DATA1 DW ‘T’
DATA2 DW ‘t’
.CODE
MOV AX,DATA1
MOV DX,DATA2
MOV DATA1,DX
MOV DATA2,AX
The above
processes will exchange the ASCII values of ‘T’ and ‘t’
TASK 4:
.DATA
DATA DB ‘JKML$’
.CODE
MOV AH,[BX] ;CONVERTING TO LOWER CASE
ADD AH,20H
The above
process move value J into AH and adding 20H will convert it into lower case
Then for the
next character K
INC BX ;POINT TO NEXT CHARACTER
IN BX
This will go
to next character K and lower case of K can be taken by the above process
We will
perform same process for remaining characters.
TASK 5:
.DATA
A DB 2D ;WE ARE DEFINING DECIMALS
B DB 3D
In code
section we can simply apply ADD and MUL instructions according to the formula.
TASK 6:
Assemble the file:
Masm
TASK6.asm
Linking the object file:
Link
Task6.obj
Loading the file in debugger:
Debugger Task6.exe
To check the status of flags we use
“t”
By executing
each instruction one by one we can check the status of each flag
After execution of instruction 1:
Sf=0,Zf=0,Af=0,Pf=0,Of=0,Cf=0
After execution of instruction 2:
Sf=0,Zf=0,Af=0,Pf=0,Of=0,Cf=0
After execution of instruction 3:
Sf=0,Zf=0,Af=1,Pf=0,Of=0,Cf=0
After execution of instruction 4:
Sf=0,Zf=0,Af=1,Pf=1,Of=0,Cf=1
After execution of instruction 5:
Sf=0,Zf=0,Af=1,Pf=1,Of=0,Cf=1
Task 7:
First in
data segment ,we have to define to memory locations we are using in the
program.As in the required output ,we have to display a row with proper spaces and on new line the next
row.Similarly,the result of them in another row.
IN .DATA
section of the program,we define bytes ,For new line and space ,as in ASCII
table LF(line feed) and CR(carriage return) are used .We will define them in
bytes like
LF EQU 0AH
CR EQU 0DH
MATRIX DB LF,CR,’FOR MATRIX ONE$’ ;PROMPT MESSAGE
NL DB LF,CR, ’$’ ;TO MOVE TO NEXT LINE
TAB DB ‘ $’ ;FOR SPACE
We will
define other location similarly.These memory locations will be used when to
input data from the user.
To store the
result of their addition ,we have to define bytes like this
NF DB ?
NS DB ?
RESULT DB ? ;STORE RESULT OF CERTAIN
ELEMENTS RESPECTIVELY
Interrupts
are used in this program .Interrupts are used when we are taking user input .
An important
thing to notice is that when using interrupts ,the data stored in DX is
used.Means the data which is stored last in the DX will be used in interrupts.
In .CODE
section
MOV DX,OFFSET MATRIX
MOV AH,09H ;THIS
WILL DISPLAY THE STRING LAST STORED IN DX
INT 21H
;09H IS FOR INPUT FOR STRINGAND 21H IS INTERUPT
To input
numbers from user
MOV AH,1H
INT 21H
The data
input from user is then stored in memory location for further addition
MOV DH,AL
MOV NF,DH
When to add
numbers,important thing to notice that numbers we input are stored in hexadeximal
so first we have to convert it into decimal
MOV CL,NS
SUB DH,30H
SUB CL,30H
ADD DH,CL
Then they
are added ,But to show them we have to convert them into hexadecimal again
ADD DH,30H
MOV SUM,DH ;STORING RESULT IN
SUM
Similarly
for other elements input we will perform the above actions repeatedly.
To output on
the screen
MOV DL,NF ;DISPLAY
CONTENTS OF NF
MOV AH,2
INT 21H
To show
other outputs and spaces and newline.We will perform the appropriate tasks accordingly.
TASK 8:
For new line
and position of cursor ,the process is described above.
MSG DB LF,CR, ‘ENTER CHARACTER IN
LOWER CASE$’
SPACE EQU 20H
Important
thing to notice about EQU ,is that EQU doesn’t occupy memory location .It only provides
a constant to a label.
.DATA
SECTION
CHAR1 DB ?
In .CODE
SECTION
MOV AH,1H ;TO USER INPUT
INT 21H
MOV DH,AL
SUB DH,20H ;TO CONVERT LETTER TO UPPERCASE
0 comments:
Post a Comment