Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // multiply all the numbers in a array with 2
  2.  
  3. word aSize 8 // length of array a
  4. word a 1 2 3 4 4 3 2 1 // my array
  5. word res 0x80
  6. loadc r3 2
  7.  
  8. // Compute start address
  9. loadc r1 a // r1 = &a[0] (the address of a[0])
  10.  
  11. // Compute where to stop
  12. loadc r0 a // r1 = &a[0]
  13. load r2 aSize // r2 = number of elements in a
  14. add r2 r2 r2 // r2 = 2*r2 = number of bytes in a
  15. add r0 r0 r2 // r0 = &a[aLen] (first address after array)
  16.  
  17. // Compute where to store the results
  18. load r7 res
  19.  
  20. loadc r5 0 // r5 used to store the certain number multiplied with 2
  21. Loop: loadr r2 r1 // r2 = a[i]
  22. mul r5 r2 r3 // r5 = r2*r3
  23. storer r5 r7 // store r5 in the location stored in r7
  24. addc r1 2 // i++
  25. addc r7 2 // move the location in r7
  26. jumpn r1 Loop // if &a[i] != &a[8] goto Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement