ARM Assembly code for block transfer of data

    ARM processor is used in all the Embedded systems that are being built now.ARM has both 32-bit and 64-bit RISC multi-core processors. RISC processors are designed to perform a smaller number of types of computer instructions so that they can operate at a higher speed, performing more millions of instructions per second. By stripping out unneeded instructions and optimizing pathways, RISC processors provide outstanding performance at a fraction of the power demand of CISC (complex instruction set computing) devices.
 So, now let's see how write a ARM assembly program for block transfer of data.

ALGORITHM
  1. Start
  2. Create a array of numbers in memory( say internal memory)
  3. Initialize a counter register to number of elements in memory
  4. Load base address of array to a register
  5. Load value to a temporary register from source memory
  6. Store the value in destination memory
  7. Decrement counter value
  8. Repeat steps 5-7 till counter value becomes zero
  9. Stop
Here is a example code for block transfer of 10 numbers from memory location 0x40000000 to 0x50001000.

CODE

      AREA program,CODE,READONLY
      ENTRY
      LDR R0,=0x40000000   ; Source memory base address 
      LDR R1,=0x50001000   ; Destination memory base address
      MOV R2,#0x0A         ; Counter register with value equal to number of elements in source memory
label LDR R3,[R0],#4       ; Loading value to temporary register
      STR R3,[R0],#4       ; Storing the value at destination memory
      SUB R2,R2,#1
      CMP R2.#00
      BNE loop
      END

No comments:

Powered by Blogger.