Program to move contents in memory-machine level programs, Assembly Language

Example : Write a program to move the contents of the memory location 0500H to BX and also to register CX. Add immediate byte 05H to the data residing in memory location, whose address is computed by using DS=2000H and offset=0600H. Store up the result of the addition in 0700H. Consider that the data is located in the segment specified by the data segment register which contain 2000H.

Solution :

The flow chart for the program is shown in given figure.

After initializing the data segment register the content of the location 0500H are moved to the BX register by using MOV instruction. The similar data is moved also to the CX register. For this data transfer, there can be 2 options as shown.

1739_example1.jpg

826_example2.jpg

(a) MOV CX,       BX      ; As the contents of BX register will be similar as 0500H after execution

                                   ; of MOV BX,[0500H].

(b) MOV CX, [050OH]   ; Move directly from 0500H to CX

 

In the first option the opcode is just of 2 bytes, whereas the second option will have 4 bytes of opcode. Thus the second option will need execution time and more memory. Due to these reasons, the first option is preferable.

The immediate data byte 05H is added to content of 0600H by using the ADD instruction. The result will be goes in destination operand 0600H. It is next stored at the location 0700H. In particular case of the 8086/8088 instruction set, there is no instruction for direct transfer of data from the memory source operand to the memory destination operand rather than the string instructions. So the result of addition which is present at 0600H should be moved to any one registration amongst the general purpose registers, except BX and CX, or else the contents of BX and CX will be changed. We have chosen DX (we could have selected register AX also, because once DS is initialized to 2000H the contents of register AX are no longer useful for this purpose. therefore the transfer of result from 0600H to 0700H is accomplished in two stages by using successive MOV instructions, for an instance,

Firstly, the content of 0600H is DX register and then the content of DX register is moved to 0700H. The program terminated with the instruction HLT.

 

Posted Date: 10/12/2012 6:32:47 AM | Location : United States







Related Discussions:- Program to move contents in memory-machine level programs, Assignment Help, Ask Question on Program to move contents in memory-machine level programs, Get Answer, Expert's Help, Program to move contents in memory-machine level programs Discussions

Write discussion on Program to move contents in memory-machine level programs
Your posts are moderated
Related Questions
Write a program to mask bits D3D2D1D0 and to set bits D5D4 and to invert bits D7D6 of ax register

Write a program that defines symbolic constants for all of the days of the week

As an instance of the normal priority mode, imagine that initially AEOI is equal to 0 and all the ISR and IMR bits are clear. Also consider that, as shown in given figure, requests

do you type assembly code or machine code instructions like b8 0100000 to add to register EAX straigt onto dos command line or do you have to same in a file and what extension woul

Assembly Language: Inside the 8085, instructions are really stored like binary numbers, not a very good manner to look at them and very difficult to decipher. An assembler is

i have trying to do the homework but there is a mistake. (Counting positive and negative numbers and computing the average of numbers) write a program that reads an unspecified nu

move a byte string ,16 bytes long from the offset 0200H to 0300H in the segment 7000H..

The 486 Introduced in the year 1989 the 80486 did not feature any radically new processor technology. Instead, it joints a 386 processor, a cache memory controller and a math c

Description Write a MIPS program that reads a string from user input, reverse each word (defined as a sequence of English alphabetic letters or numeric digits without any punctu

RET : Return from the Procedure:- At each CALL instruction, the register IP and register CS of the next instruction is pushed to stack, before the control is transferred to the