Compile-time calculation: Difference between revisions

→‎{{header|6502 Assembly}}: let cl65 provide the header
(→‎{{header|6502 Assembly}}: Add implementation.)
(→‎{{header|6502 Assembly}}: let cl65 provide the header)
Line 66:
fac = $61 ; location of the floating point accumulator used by ROM routines
facsgn = fac+5 ; specific location of the sign byte
 
sys = $9e ; BASIC token for the SYS command to call our ML routine
 
start_of_basic = $0801 ; where our code is loaded
 
; ROM routines used
Line 78 ⟶ 74:
movfm = $bbd4 ; copy FAC to memory
 
.code
; custom BASIC loader
.word start_of_basic
.org start_of_basic
.word last_line
.word *
.byte sys
.byte $30 + < (main/1000)
.byte $30 + <((main .mod 1000)/100)
.byte $30 + <((main .mod 100)/10)
.byte $30 + < (main .mod 10)
.byte 0
last_line:
.word 0
 
; 65536 as a float for multiplying the top half
fp65536: .byte 145,0,0,0,0,0
 
; the actual value to print
tenfactorial: .dword 10*9*8*7*6*5*4*3*2*1
 
; a place to stash partial results whlie using the FAC for other operations
fac_copy: .res 6
 
main:
; convert the upper half
ldy tenfactorial+2
Line 141 ⟶ 114:
; and print out the result
jsr putfac
rts</lang>
 
.data
 
; 65536 as a float for multiplying the top halfoperations
fp65536: .byte 145,0,0,0,0,0
 
; the actual value to print
tenfactorial: .dword 10*9*8*7*6*5*4*3*2*1
 
.bss
; a place to stash partial results whlie using the FAC for other operations
fac_copy: .res 6</lang>
 
{{Out}}
1,480

edits