Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // multiply all the numbers in a array with 2
- word aSize 8 // length of array a
- word a 1 2 3 4 4 3 2 1 // my array
- word res 0x80
- loadc r3 2
- // Compute start address
- loadc r1 a // r1 = &a[0] (the address of a[0])
- // Compute where to stop
- loadc r0 a // r1 = &a[0]
- load r2 aSize // r2 = number of elements in a
- add r2 r2 r2 // r2 = 2*r2 = number of bytes in a
- add r0 r0 r2 // r0 = &a[aLen] (first address after array)
- // Compute where to store the results
- load r7 res
- loadc r5 0 // r5 used to store the certain number multiplied with 2
- Loop: loadr r2 r1 // r2 = a[i]
- mul r5 r2 r3 // r5 = r2*r3
- storer r5 r7 // store r5 in the location stored in r7
- addc r1 2 // i++
- addc r7 2 // move the location in r7
- jumpn r1 Loop // if &a[i] != &a[8] goto Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement