Answer:

         MOV #777, R0  ; address
         CLR R1        ; number of matches
   LOOP: CMPB (R0)+, @R0
         BNE NOMATCH
         INC R1
NOMATCH: CMP R0, #2000
         BLT LOOP
         HALT          ; answer in R1

Note that the above code also compares [777] == [1000]. If you read the question carefully you will see that this is required. In grading, I ignored the boundary issues on either side of the range 1000 to 1777.


[exam] [CSC 258 additional problems] [main course page]