************************************************************** * * * Nathan Balon * * SN# 3210 1717 * * CIS 310 * * Winter 2004 * * * * Program #1 * * The programs the total amount of money in a piggy bank. * * The results are then displayed on the screen. * * * ************************************************************** ************************************************************ * Execution Section * ************************************************************ ORG $400 Program orgin BSR PRT_HEAD Display the program heading information BSR PRT_BODY Display the information on the number of coins CLR D5 CLR D6 LEA COIN_VAL,A3 LEA COIN_AMT,A4 LEA COIN_TOT,A5 NEXT CMP.B #3,D6 BEQ CONT BSR CALC_TOT BRA NEXT CONT BSR PRT_END Display the footer information EXIT STOP #$2700 Halt processor at end of program ********************************************************** * Sub-routines * ********************************************************** CALC_TOT CLR D2 MOVE.B (A3)+,D2 MOVE.W (A4)+,D3 MULU.W D3,D2 MOVE.L D2,(A5)+ ADD.L D2,D5 MOVE.L D5,TOT_CENTS ADDQ.B #1,D6 MOVE.B D6,COUNT RTS PRT_NUM MOVE.B #8,D6 Eight hex characters to print LOOP ROL.L #4,D2 Get the most significant 4 bits in least significant nibble MOVE.B D2,D7 Copy the least significant byte to d3 for processing ANDI.L #$0000000F,D7 Clear all of d3 except the least significant nibble MOVEA.L D7,A5 A0 contians the binary values of the character to be printed MOVE.B (TRANS,A5),D3 Read the ASCII character to be displayed MOVE.W #1,D1 Display the character MOVE.B D3,(A1) TRAP #15 SUB.B #1,D6 subtact 1 from the loop counter BNE LOOP Repeat the loop until all eight characters are read RTS PRT_HEAD MOVE.B #0,D0 Set print option LEA NAME,A2 MOVEA.L A2,A1 Display my name MOVE.W #12,D1 TRAP #15 LEA CLASS,A1 Display the class MOVE.W #7,D1 TRAP #15 LEA TIME,A1 Display the class time MOVE.W #12,D1 TRAP #15 MOVE.B #SP,(A1) MOVE.W #1,D1 Display blank line TRAP #15 LEA INPUT,A1 Display the title input MOVE.W #5,D1 TRAP #15 MOVE.B #SP,(A1) MOVE.W #1,D1 Display blank line TRAP #15 RTS PRT_BODY MOVE.B #4,COUNT LEA COIN_LBL,A2 Pointer to display name of coin LEA COIN_AMT,A3 Pointer to amount of coin LP CLR.L D1 MOVE.B #1,D0 Set print option MOVE.B #TB,(A1) Display a tab MOVE.W #1,D1 TRAP #15 MOVEA.L A2,A1 DISPLAY COIN NAME ADDA.L #8,A2 MOVE.W #8,D1 TRAP #15 MOVE.B #TB,(A1) Display a tab MOVE.W #1,D1 TRAP #15 CLR D2 MOVE.W (A3)+,D2 BSR PRT_NUM MOVE.B SP,(A1) MOVE.B #0,D0 MOVE.W #1,D1 TRAP #15 MOVE.B COUNT,D7 SUB.B #1,D7 MOVE.B D7,COUNT BNE LP RTS PRT_END MOVE.L TOT_CENTS,D2 DIVU.W #100,D2 MOVE.W D2,DOLLARS SWAP D2 MOVE.W D2,CENTS MOVE.B #0,D0 MOVE.B #SP,(A1) MOVE.W #1,D1 Display blank line TRAP #15 LEA OUTPUT,A1 Display the title input MOVE.W #6,D1 TRAP #15 MOVE.B #1,D0 MOVE.B #TB,(A1) Display a tab MOVE.W #1,D1 TRAP #15 LEA END0,A1 MOVE.W #7,D1 TRAP #15 CLR D2 MOVE.W DOLLARS,D2 BSR PRT_NUM LEA END1,A1 MOVE.W #13,D1 TRAP #15 CLR D2 MOVE.W CENTS,D2 BSR PRT_NUM LEA END2,A1 MOVE.W #6,D1 TRAP #15 RTS *********************************************************** * Data Section * *********************************************************** ORG $1000 data orgin * * Labels to be printed out in the program * SP EQU $20 TB EQU $09 HEADING EQU * NAME DC.B 'Nathan Balon' CLASS DC.B 'CIS 310' TIME DC.B 'Winter, 2004' INPUT DC.B 'Input' * COIN_LBL EQU * Q_LBL DC.B 'Quarters' D_LBL DC.B 'Dimes ' N_LBL DC.B 'Nickel ' P_LBL DC.B 'Pennies ' * Output DC.B 'Output' end0 DC.B 'I have ' end1 DC.B ' dollars and ' end2 DC.B ' cents' * * Values used to convert to ASCII * TRANS DC.B '0123456789ABCDEF' * * Define the values for each coin * COIN_VAL DC.B 25 value of a quarter is 25 DC.B 10 value of a dime is 10 DC.B 5 value of a nickel is 5 DC.B 1 value of a penny is 1 * * Define storage to hold the totals * COIN_TOT DS.L 1 DS.L 1 DS.L 1 DS.L 1 * * Amount of each coin * COIN_AMT DC.W 175 DC.W 139 DC.W 201 DC.W 1003 * * Other variables used * TOT_CENTS DS.L 1 DOLLARS DS.W 1 CENTS DS.W 1 COUNT DS.B 1 END $400