; Program AV. ; On entry L contains "return" address ; A points to a two word area ; 1'th word is for the result ; 2'th word contains a small pos integer, n ; On exit First word of two word area contains the ; integer part of the average of the squares ; of the first n positive integers. ; Second word is unchanged ; This routine uses registers A X L EQU wordsize 3 START eg2 512 ; Hex 200 EQU resadr * RESW 1 EQU nadr * RESW 1 EQU av * ; The next STA instruction is where we ; want to begin execution -- STA - resadr ADD # wordsize STA - nadr CLEAR A STA @ resadr ; res := 0 CLEAR X ; counter := 0 EQU loop * TIX @ nadr JGT - ndivide RMO X A MULR A A ADD @ resadr STA @ resadr ; res := res + count**2 J # loop EQU ndivide * LDA @ resadr DIV @ nadr STA @ resadr ; res := av of squares RSUB END av