****************************************************** * NEG2.SRC * ****************************************************** CODE EQU $8000 ;program starts at $8000 DATA EQU $9000 ;data starts at $9000 ORG CODE ;program at $8000 NEG2 MOVEA.L #DATA,A0 MOVE.B (A0)+,D0 ;use D0 as counter CLR.B (A0)+ ;clear RESULT MOVEA.L (A0),A1 ;A1 points to numbers LOOP TST.B (A1)+ ;test number BPL.S SKIP ;negative? ADDQ.B #1,-1(A0) ;yes: increment RESULT SKIP SUBQ.B #1,D0 ;no: decrement counter BNE LOOP ;repeat until count = 0 TRAP #14 * * Use DC directives to initialize RAM * ORG DATA ;data at $9000 LENGTH DC.B 4 RESULT DC.B 0 START DC.L $9040 ORG $9040 DC.B $25,$80,$7F,$55 END NEG2