.TITLE Average Version 8 ;Section 3.1, page 85 ;This program will calculate the average of ; three numbers X(0), X(1), and X(2). The result will be ; saved in location Ave. X: .WORD 1560 ;Create storage for the .WORD 1432 ; data .WORD 2167 Ave: .BLKW 1 ;Save room for the answer .ENTRY AVERAGE, 0 Begin: MOVAW X,R6 ;Move address of X into R6 ; This will serve as the base ; address CLRL R4 ;R4 will contain the index MOVW (R6)[R4],R5 ;R5 now contains X(0) INCL R4 ;Increment the index ADDW2 (R6)[R4],R5 ;R5 contains X(0) + X(1) INCL R4 ;Increment the index ADDW2 (R6)[R4],R5 ;R5 contains the final sum DIVW3 #3,R5,AVE ;Ave contains R5/3 Done: $EXIT_S .END AVERAGE