Public paste
AHHHH
By: microhaxo | Date: Jun 26 2009 23:45 | Format: None | Expires: never | Size: 890 B | Hits: 501

  1. .begin
  2. .org 2048
  3.         mov %r0, %r20   ! %r20 = memory offset
  4.         mov %r0, %r21   ! %r21 = SUM
  5. AddThree:
  6.         ld [ INPUT + %r20 ], %r10  ! loading the list and placing it in register 10
  7.         add %r10, %r21, %r21            ! moving it around
  8.         subcc %r10, 0, %r0              ! conditional subtraction
  9.         add %r20, 4, %r20               ! not sure why this needs to happen
  10.         add %r22, 1, %r22               ! this is my counter :)
  11.         cmp %r22, 3                     ! if its not true then move on
  12.         bne AddThree                    ! NOT ZERO Branch
  13. StoreResult:
  14.         mov %r21, %r4                   ! moving the answer to store it
  15.         st %r4, [OUTPUT]                ! storing in the location OUTPUT
  16.         mov %r0, %r21                   ! Resetting things
  17.         mov %r0, %r22                   ! Resetting the counter
  18.         halt
  19.  
  20. INPUT:  10
  21.           10
  22.           10
  23.           20
  24.           20
  25.           20
  26.           30
  27.           30
  28.           30
  29.           40
  30.           40
  31.           40
  32.           0
  33.           0
  34.           0
  35. OUTPUT:  
  36.  
  37. END:
  38.  
  39. .end