URL
https://opencores.org/ocsvn/rtf65002/rtf65002/trunk
Subversion Repositories rtf65002
[/] [rtf65002/] [trunk/] [software/] [asm/] [pi_calc816.asm] - Rev 40
Compare with Previous | Blame | View Log
; ============================================================================; __; \\__/ o\ (C) 2014 Robert Finch, Stratford; \ __ / All rights reserved.; \/_// robfinch<remove>@finitron.ca; ||;;; This source file is free software: you can redistribute it and/or modify; it under the terms of the GNU Lesser General Public License as published; by the Free Software Foundation, either version 3 of the License, or; (at your option) any later version.;; This source file is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with this program. If not, see <http://www.gnu.org/licenses/>.;; This code calculates PI to 360 digits. It runs on a 65C816 processor.; The code was found at www.6502.org; ============================================================================;P EQU 2Q EQU 1193*2 + 2R EQU Q + 2SSS EQU R + 2jsr INITSUBldx #359ldy #1193L1S:phyphaphxstz Q; txa; ldx #5; wdm; xce; cpu RTF65002; jsr PRTNUM; clc; xce; cpu W65C816S; rep #$30; plx; phxtyataxL2S:txa; phx; ldx #5; wdm; xce; cpu RTF65002; jsr PRTNUM; clc; xce; cpu W65C816S; rep #$30; plx; txajsr MULSUBsta SSSlda #10sta Qjsr ADJ1SUBlda P-1,xjsr UNADJ1SUBjsr MULSUBclcadc SSSsta Qtxaasldeajsr DIVSUBjsr ADJ1SUBsta P-1,xjsr UNADJ1SUBdexbne L2Slda #10jsr DIVSUBsta Pplxplaldy Qcpy #10bcc L3Sldy #0inaL3S:cpx #358bcc L4Sbne L5Sjsr OUTPUTSUBlda #46L4S:jsr OUTPUTSUBL5S:tyaeor #48plycpx #358bcs L6SdeydeydeyL6S:dexbeq L7Sjmp L1SL7S:jsr OUTPUTSUBwdmxcecpu RTF65002rtscpu W65C816SINITSUB:lda #2ldx #1192IS1:jsr ADJSUBsta P,xjsr UNADJSUBdexbpl IS1rtsMULSUB:sta Rldy #16M1S: aslasl Qbcc M2Sclcadc RM2S: deybne M1SrtsDIVSUB:sta Rldy #16lda #0asl QD1S: rolcmp Rbcc D2Ssbc RD2S: rol Qdeybne D1SrtsADJSUB:phatxaasltaxplartsUNADJSUB:phatxalsrtaxplartsADJ1SUB:phatxaasltaxpladexrtsUNADJ1SUB:phatxalsrtaxplainxrtsOUTPUTSUB:; switching back to '816 mode will force the registers to 8 bit, so we; have to save off their values, then restore them after the switchwdm ; switch to 32 bit modexcecpu RTF65002jsr DisplayCharclc ; switch back to 816 modexcecpu W65C816Srts
