Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C while loops into assembly ??

Name: Anonymous 2007-09-12 5:23 ID:ETNdMjth

Consider the C code function below:

void qwerty(int *x, int *y, int size)
{
  int k=0;
  while ( k < size ) {
     *(x + k) = *(y + k);
     k++;
   }
}

ii) Construct an ARM assembly code version which implements the C code within the function qwerty. You may assume that registers a1 and a2 contain the pointers x and y respectively, and that register a3 contains the size argument.

Name: Anonymous 2007-09-12 5:46 ID:GXLCMnVM

;SIMPLE memcpy IN 6502
;THIS IS NOT ARM ALTHOUGH IT LOOKS LIKE IT
;YOUR TEACHER MAY NOT KNOW THE DIFFERENCE THOUGH

;2 POINTERS NEEDED IN ZERO PAGE
;YOUR ARCHITECTURE MAY NEED DIFFERENT ONES
;THIS WORKS ON COMMODORE 64
PSOURC = 251 ;SOURCE POINTER
PTARG  = 253 ;TARGET POINTER

;SIZE MINUS ONE IS IN .Y, .Y=0 COPIES 256 BYTES
MEMCPY LDA (PSOURC),Y
       STA (PTARG),Y
       DEY
       BNE MEMCPY
DONE   RTS

;OH BTW, FOR A LITTLE BIT OF PERFORMANCE YOU NEED TO MAKE YOUR
;START AT THE HIGHEST VALUE AND THEN END AT 0, TO TAKE ADVANTAGE
;OF THE ZERO FLAG IN THE STATUS REGISTER!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List