* *``````````````````````````````* * ADD16 :: ADD 16-BIT VALUES * *- -* * ADDS TWO SIXTEEN BIT VALUES * * AND RETURNS A 16 BIT VALUE * * IN Y (LOW) AND X (HIGH). * *- -* * CLOBBERS: * * * * FLAGS: ????---- REG: AXYM * *- -* * CYCLES: ??? * * SIZE: * *- -* * USAGE: * * * * LDA #>1000 * * PHA * * LDA #<1000 * * PHA * * LDA #>1200 ; ADD2 * * PHA * * LDA #<1200 * * PHA * * JSR ADD16 * *- -* * ENTRY * * * * TOP OF STACK * * * * LOW BYTE OF RETURN ADDRESS * * HI BYTE OF RETURN ADDRESS * * ADDEND 2 LOW BYTE * * ADDEND 2 HIGH BYTE * * ADDEND 1 LOW BYTE * * ADDEND 1 HIGH BYTE * *- -* * EXIT * * * * TOP OF STACK * * * * LOW BYTE OF RETURN ADDRESS * * HI BYTE OF RETURN ADDRESS * * * * Y = LOW BYTE OF RESULT * * X = HIGH BYTE OF RESULT * * A = LOW BYTE OF RET ADDR * *- -* * ADAPTED FROM LEVANTHAL AND * * WINTHROP'S /6502 ASSEMBLY * * LANGUAGE ROUTINES/. * * AS SUCH, THIS MAY NOT FALL * * UNDER THE APACHE 2.0 LICENSE * * AGREEMENT, SINCE THE BOOK * * WAS WRITTEN BEFORE THE * * LICENSE! * * * * THAT SAID, LEVENTHAL WROTE * * THAT THE PURPOSE OF THE BOOK * * WAS TO COPY THE SOURCE CODE, * * AS REINVENTING THE WHEEL IS * * TEDIOUS, AND HE PLACED NO * * RESTRICTIONS ON ITS USE. * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * ADD16 * ** GET RETURN ADDR * PLA STA :RETADR PLA STA :RETADR+1 * ** GET PARAMETERS * PLA STA :ADD2 PLA STA :ADD2+1 PLA STA :ADD1 PLA STA :ADD1+1 * LDA :ADD1 CLC ADC :ADD2 TAY ; LOW BYTE LDA :ADD1+1 ADC :ADD2+1 TAX ; HIGH BYTE * ** RESTORE RETURN ADDRESS * LDA :RETADR+1 PHA LDA :RETADR PHA * RTS * ** DATA * :RETADR DS 2 :ADD1 DS 2 :ADD2 DS 2