Question

In: Computer Science

Write a program segment to copy a table with five items from a memory location starting...

Write a program segment to copy a table with five items from a memory location starting at $5000 to a memory location starting at $6000.

Solutions

Expert Solution

Algorithm –

  1. set the value of offset SI equal to 5000.
  2. set the value of offset DI equal to 6000.
  3. load the value 0000 into register AX.
  4. load the data of AX register into DS(data segment).
  5. load the data of AX register into ES(extra segment).
  6. load the data of offset SI into CL register and load value 00 into CH register.
  7. increment the value of SI by one.
  8. clear the directional flag so that data is read from lower memory to higher memory location.
  9. check the value of CX, if not equal to zero then repeat step 10 otherwise go to step 11.
  10. transfer the data from source memory location to destination memory location and decrease the value of CX by one.
  11. Stop.

ADDRESS

MNEMONICS

COMMENTS

0400

MOV SI, 5000

SI<-5000

0403

MOV DI, 00

DI<-6000

0406

MOV AX, 0000

AX<-0000

0409

MOV DS, AX

DS<-AX

040B

MOV ES, AX

ES<-AX

040D

MOV CL, [SI]

CL<-[SI]

0410

MOV CH, 00

CH<-00

0412

INC SI

SI<-SI+1

0413

CLD

Clears the directional Flag

0414

REP

repeat until CX is not equal to zero
and CX=CX-1 at every step

0415

MOVSB

transfer the data from source to destination memory location

0416

HLT

end

Explanation:-


MOV SI, 5000: load the value 5000 into offset SI.

MOV DI, 6000: load the value 6000 into offset DI.

MOV AX, 0000: load the value 0000 into AX register.

MOV DS, AX: load the value of AX register into DS (data segment).

MOV ES, AX: load the value of AX register into ES (extra segment).

MOV CL, [SI]: load the data of offset SI into CL register.

MOV CH, 00: load value 00 into CH register.

INC SI: increment the value of SI by one.

CLD: clears the directional flag i.e. DF=0.

REP: repeat until value of CX is not equal to zero and decrement the value of CX by one at each step.

MOVSB: transfer the data from source memory location to destination memory location.

HLT: end.


Related Solutions

HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location...
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000
-If we assume we place the following MIPS code starting at location 8000 in memory, what...
-If we assume we place the following MIPS code starting at location 8000 in memory, what is the MIPS machine code for this code? Show the machine codes in decimal. Please explain each instruction and specify its type ( R format, I format, or J format). k corresponds to register $s4, j corresponds to register $s1, i corresponds to register $s0, and the base of the array v is in $a0 addi $s1,$s0,-1 label2: slti $t0, $s1, 0 bne $t0,...
I have a char memory[1024]. I want to write the string "mike" into the memory starting...
I have a char memory[1024]. I want to write the string "mike" into the memory starting from an index. I also need a function to move "mike" to another index in the same memory swapping m and k in mike. Basically, i need a function to write to memory and a function to move the string to an index. Thank you In c++ please.
Please write program in C++ format: Write a program to accept five negative numbers from the...
Please write program in C++ format: Write a program to accept five negative numbers from the user. (1) Find the average of the five numbers and display the answer to the standard output. Keep the answer two decimal points - 5 points (2) Output the numbers in ascending order and display the answer to the standard output. - 5 points
Python 1. A salesman can sell five different items. Write a program that lets the salesman...
Python 1. A salesman can sell five different items. Write a program that lets the salesman enter the quantity of each item sold, calculates the total sales, and prints as below. Use a for loop to ask the salesman how many of each product he sold. tem 1 $2.50 Item 2 $1.98 Item 3 $5.75 Item 4 $3.45 Item 5 $4.00 2. Rewrite program #1 using a for loop to run for 3 salesmen and print the total sales for...
what is Protection? what is Fill on demand? what is Copy on write? what is Memory...
what is Protection? what is Fill on demand? what is Copy on write? what is Memory mapped files? what is Web server role? what is Virtual machines? what is Fault tolerance?
Write a program in Easy68K: a) Define an array of numbers in the memory.
Write a program in Easy68K: a) Define an array of numbers in the memory. b) Read two numbers from keyboard. The first number is the size of the array and the second number is what index of the array you want to access. The index you entered can be larger than the array. c) Display the element indexed by (index % size) in the array. 
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to 2FFF & transfer to 4000 to 4FFF
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT