16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 Bit14 Bit13 Bit12 Bit11 B
ID: 3595542 • Letter: 1
Question
16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 Bit14 Bit13 Bit12 Bit11 Bit10 Bit9 Bits8 Bit7 Bit6 BitS Bit4 Bit3 Bit2 Bit1 Bito Bit8 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bito ID: Tech 160 fall 2017 M Zand Midterm #1 Name Problem 3-20 Write an assembly program that moves the content of the data memory upward by 2 bytes. Please use the lengthof instruction to get the number of the elements in the data. Example Before After Addr data Addr data 1000 1001e 1002 L 1003 1004 o 1005 M 1006Y 1007 1008 1000? H 1001 1002 H 1003 e 1004 L 1005 L 1006 o 1007 m 1008y de n PEOCExplanation / Answer
DATA SEGMENT
X DB 01H,02H,03H,04H,05H ; Initialize Data Segments Memory
Locations
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA ; Initialize the DS to point to start of the memory
MOV DS,AX ; setting aside for storing of data
MOV CX,05H ; Loading the counter
LEA SI,X+04 ; Making the SI pointer pointed to top of the memory block
LEA DI,X+04+03 ; 03 is displacement of over lapping where DI pointed to the top of the destination block
UP: MOV BL,[SI] ; Move the SI content to BL register
MOV [DI],BL ; Move the BL register to content of DI
DEC SI ; Update SI and DI
DEC DI
DEC CX ; Decrement the counter till it becomes zero
JNZ UP
MOV AH,4CH
INT 21H
CODE ENDS
This will give exactly the same output shown above.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.