Created
October 20, 2012 19:59
-
-
Save emberian/3924572 to your computer and use it in GitHub Desktop.
a program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORG $400 | |
LEA STRING,A1 a1 points to mem to be printed | |
MOVE.B #14,D0 d0 holds our trap code | |
TRAP #15 print from a1 | |
LEA SPACE,A1 point a1 to space | |
TRAP #15 print space | |
MOVEA.L #DATA,A0 point a0 at our data list | |
ADD ADD.B (A0),D1 d1 holds the sum | |
ADDA.L #1,A0 increment a0 | |
ADD.L #1,D2 d2 holds our counter | |
CMP.L #15,D2 compare d2 to 15 | |
BNE ADD if d2 is not 15 loop again | |
MOVE.B D1,D3 store mean in d3 | |
DIVU #15,D3 divide sum by 15 for mean | |
MOVE.B #0,D2 reset our counter | |
MOVE.L D3,$500 move the mean to 500 in mem | |
MOVE.B #3,D0 int print code | |
MOVE.L $500,A1 load mean into a1 | |
TRAP #15 print mean from a1 | |
MOVE.B #14,D0 d0 holds our trap code | |
LEA SPACE,A1 point a1 to space | |
TRAP #15 print space | |
MOVEA.L #DATA,A0 point a0 at our data list | |
CLR D2 clear our d2 counter | |
VARI MOVE.B (A0),D1 d1 holds each number | |
ADDA.L #1,A0 | |
SUB.B D3,D1 subtract mean from num | |
MULU D1,D1 square d1 | |
ADD.B D1,D4 add result to variance | |
ADD.L #1,D2 increment counter | |
CMP.L #15,D2 compare counter to 15 | |
BNE VARI if counter is not 15 do it again | |
DIVU #15,D4 divide variance by mean | |
MOVE.L D4,$600 store variance into 600 | |
MOVE.L $600,A1 load variance into a1 | |
MOVE.B #3,D0 int print code | |
TRAP #15 print variance | |
STOP #$2700 | |
* | |
ORG $1000 | |
STRING DC.B 'Nicholas Busse',0 | |
SPACE DC.B ' ',0 | |
DATA DC.B 10,12,8,17,9,22,18,11,23,7,30,22,19,6,7 | |
END $400 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment