t64_arrays.pas 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. program t64_arrays;
  2. { t64 -- array TYPES and array typed constants: the 2-D sheet and XPOS.
  3. CALC.PAS:133 and :137:
  4. Cells = array['A'..'G',1..FYMax] of CellRec; (FYMax = 21)
  5. XPOS : array['A'..'G'] of Integer = (3,14,25,36,47,58,68);
  6. Ranges are row-major with the LAST varying fastest, and both ranges are
  7. stored in an ArrRec the symbol points at, so the shape survives for
  8. indexing. `Sheet' is 7 * 21 * 80 = 11760 bytes; `XPOS' is 7 * 2 = 14.
  9. An array TYPED CONSTANT cannot fold to a word, so - like a set - its bytes
  10. are emitted in the code stream behind a JMP and the name becomes an
  11. addressable value; each element is written little-endian in the element's
  12. bytes. So XPOS does NOT appear in the data area: data=11764 is Sheet
  13. (11760) + the two @@T temporaries, and XPOS's 14 bytes are in the code
  14. stream (code=67). That is the storage decision showing up in the numbers.
  15. Array ELEMENT ACCESS (`Sheet[fx,fy]', `XPOS['C']') is the next increment: an
  16. element's width is not the array's, so a subscript is a LOUD error today
  17. rather than a store of the whole array. }
  18. type
  19. Attributes = (Constant, Formula, Txt, OverWritten, Locked, Calculated);
  20. CellRec = record
  21. CellStatus : set of Attributes;
  22. Contents : String[70];
  23. Value : Real;
  24. DEC, FW : 0..20;
  25. end;
  26. Cells = array ['A'..'G', 1..21] of CellRec;
  27. const
  28. XPOS : array ['A'..'G'] of Integer = (3, 14, 25, 36, 47, 58, 68);
  29. var
  30. Sheet : Cells;
  31. begin
  32. writeln ('arrays declared')
  33. end.