Compile-time calculation: Difference between revisions

Line 60:
{{works with|ca65}}
 
The ca65 cross-assembler supports computing and storing double-word (32-bit) integer values; unfortunately most 86502-bitbased systems have no built-in support for manipulating such values. But the assembler also supports converting them directly to strings, which are easily printed at runtime. So, here's a straightforward implementation. As written, it works for any Commodore port:8-bits, but it could be ported to a different 6502 machine just by changing the print loop to use the appropriate output routine for the target system.
 
<lang 6502>; Display the value of 10!, which is precomputed at assembly time
Line 66:
 
.ifndef __CBM__
.error "Target must be a Commodore 8-bitsystem."
.endif
 
Line 97:
 
{{Out}}
The code should work on any Commodore 8-bit computer, from the original PET through the C-128. Here's what it looks like when run immediately upon booting a C-64:
<pre>
**** COMMODORE 64 BASIC V2 ****
1,480

edits