Long literals, with continuations: Difference between revisions

m
(→‎{{header|Haskell}}: added solution)
Line 204:
JSR PrintString</lang>
 
This routine can be expanded as new elements are discovered, but once the 128th element is discovered it will need to be reprogrammed since you can't offset more than x=255. This is actually a very simple fix, and can be accomplished by splitting the table as such:
<lang 6502asm>Elements_Lo:
db <hydrogen,<helium,<lithium,<beryllium,<boron,<carbon,<nitrogen,<oxygen,<fluorine,...
Elements_Hi:
db >hydrogen,>helium,>lithium,>beryllium,>boron,>carbon,>nitrogen,>oxygen,>fluorine,...</lang>
 
Note that < and > are unary operators that mean "the low byte of" and "the high byte of", respectively. By storing the halves of each pointer in two separate tables, sharing a common index, we can index up to 256 elements rather than 128, without increasing the total data size of the tables.
 
{{out}}
1,489

edits