Compile-time calculation: Difference between revisions

(→‎{{header|6502 Assembly}}: let cl65 provide the header)
Line 60:
{{works with|ca65 targeting the C-64}}
 
The ca65 cross-assembler supports computing and storing double-word (32-bit) integer values; unfortunately most 8-bit systems have no built-in support for manipulating such values. InOn thisCommodore solutionmachines, theunless assembleryou computeswrite theyour actualown valuearithmetic ofroutines, 10!you andhave storesto ituse asfloating apoint 32-bitinstead integerof integers for numbers that large; unfortunately the runtimeassembler codedoesn't convertssupport that togenerating floating point usingconstants. Nor is there a ROM routines,routine dealingto withconvert thea 1632-bit halvesinteger ofto ita float, even though there is one atto ago timethe other way.
 
So in this solution the assembler computes the value of 10! and stores it as a 32-bit integer; the runtime code converts that to floating point using ROM routines, dealing with it 16 bits at a time.
 
<lang 6502>; Display the value of 10!, which is precomputed at assembly time
1,480

edits