Documente Academic
Documente Profesional
Documente Cultură
KHOJI.NET
Page 1
KHOJI.NET
Page 2
KHOJI.NET
Page 3
KHOJI.NET
Page 4
KHOJI.NET
Page 5
KHOJI.NET
Page 6
KHOJI.NET
Page 7
KHOJI.NET
Page 8
KHOJI.NET
Page 9
KHOJI.NET
Page 10
KHOJI.NET
Page 11
KHOJI.NET
Page 12
KHOJI.NET
Page 13
KHOJI.NET
Page 14
KHOJI.NET
Page 15
KHOJI.NET
Page 16
KHOJI.NET
Page 17
KHOJI.NET
Page 18
KHOJI.NET
Page 19
KHOJI.NET
Page 20
KHOJI.NET
Page 21
KHOJI.NET
Page 22
KHOJI.NET
Page 23
KHOJI.NET
Page 24
KHOJI.NET
Page 25
KHOJI.NET
Page 26
KHOJI.NET
Page 27
KHOJI.NET
Page 28
KHOJI.NET
Page 29
KHOJI.NET
Page 30
KHOJI.NET
Page 31
KHOJI.NET
Page 32
KHOJI.NET
Page 33
KHOJI.NET
Page 34
KHOJI.NET
Page 35
KHOJI.NET
Page 36
KHOJI.NET
Page 37
KHOJI.NET
Page 38
KHOJI.NET
Page 39
KHOJI.NET
Page 40
KHOJI.NET
Page 41
For 16-bit segments, however, the SI and the DI registers are used to point to the
source and destination, respectively.
There are five basic instructions for processing strings. They are
KHOJI.NET
MOVS This instruction moves 1 Byte, Word or Doubleword of data from
memory location to another.
LODS This instruction loads from memory. If the operand is of one byte, it is
loaded into the AL register, if the operand is one word, it is loaded into the AX
register and a doubleword is loaded into the EAX register.
STOS This instruction stores data from register (AL, AX, or EAX) to memory.
CMPS This instruction compares two data items in memory. Data could be of a
byte size, word or doubleword.
Each of the above instruction has a byte, word, and doubleword version, and string
instructions can be repeated by using a repetition prefix.
These instructions use the ES:DI and DS:SI pair of registers, where DI and SI registers
contain valid offset addresses that refers to bytes stored in memory. SI is normally
associated with DS (data segment) and DI is always associated with ES (extra
segment).
Page 42
DATA SEGMENTSTR DB AXYBCSDEF$
SUBSTR DB BCS$
LEN1 DB 0
LEN2 DB 0
MSG1 DB 10,13,STRING IS : $
MSG2 DB 10,13,SUBSTRING IS : $
MSG3 DB 10,13,SUBSTRING IS FOUND AT POSITION : $
KHOJI.NET
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
DISPLAY MSG1
DISPLAY STR
DISPLAY MSG2
DISPLAY SUBSTR
LEA SI,STR
NXT1:
CMP [SI],$
JE DONE1
INC LEN1
INC SI
JMP NXT1
DONE1:
LEA DI,SUBSTR
NXT2:
CMP [DI],$
JE DONE2
INC LEN2
INC DI
JMP NXT2
DONE2:
DISPLAY MSG3
Page 43
LEA SI,STR
MOV AL,LEN1
SUB AL,LEN2
MOV CL,AL
MOV CH,0
FIRST:
INC POS
CMPR: INC SI
MOV AL,[SI]
CMP AL,SUBSTR[1]
JNE NOTEQUAL
KHOJI.NET
INC SI
MOV AL,[SI]
CMP AL,SUBSTR[2]
JE EQUAL
NOTEQUAL:
MOV POS,-1
DISPLAY RTN
JMP EXIT
EQUAL:
MOV DL,POS
ADD DL,30H
MOV AH,2
INT 21H
CODE ENDS
END START
Ans.4(b)
DATA SEGMENT
PACKEDBCD DB 52H
BINARY DB ? Page 44
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV AH,0
MOV AL,PACKEDBCD
AND AL,0F0H
AND BL,0FH
MOV CL,04H
ROL AL,CL
MOV CL,10
MUL CL
KHOJI.NET
ADD AL,BL
MOV AH,AL
MOV BINARY,AH
MOV AH,4CH
INT 21H
CODE ENDS
END START
Screen shots :-
Page 45
KHOJI.NET
After Execution :-
Ans.4(c)
(i). 8086 has a concept of Memory Segmentation. It is a method where the whole memory is
segmented (divided) into smaller parts called segments. These segments are
Code Segment (CS)
Stack Segment (SS)
Data Segment (DS)
Extra Segment (ES)
Each Segment has a corresponding 16-bit Segment Register which holds the Base Address
(starting Address) of the Segment. At any given time, 8086 can address 16-bit x 64KB = 256 KB
Page 46
of memory chunk out of 1MB.
8086 has 20bit address line. So the maximum value of address that can be addressed by 8086 is
2^20 = 1MB. So 8086 can address the locations ranging between 00000 H to FFFFF H. This
1MB memory is divided into 16 logical segments, each with a memory of 64KB.
In order to access memory location, you cannot pass 20-bit address directly to the processor. You
need to tell the 16-bit address with respect to the segment. This 16-bit address with respect to the
part (segment of 64KB) of the memory bank is called the offset.
KHOJI.NET
Suppose the Data Segment holds the Base Aaddress as 1000h and the data you need is present in
the 0020h memory location (Offset) of the Data Segment. The calculation of the actual address is
done as follows.
1. Left shift the 16-bit address present in the segment register by 4-bits
0001 0000 0000 0000 (0000)
2. Add the 16-bit offset address to this shifted base address
At any point of time we can change the base address of the segment registers and use the
memory locations in those segments using the offset.
Page 47
KHOJI.NET
Page 48
KHOJI.NET
Page 49
Now you can earn with us, sell your solved assignments with us and get 35% commission on
every sale of your assignment.
KHOJI.NET
No Paytm or any wallet, payment will be made directly to your bank account.
You dont have to do anything just send us your solved assignment, sit back and receive your
commission in your bank.
Only those assignments which are not available on our site are accepted.
Interested?
Page 50