t80_realconst.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. program t80_realconst;
  2. { t80 -- a REAL record field assigned from integer constants.
  3. CALC.INC:163 is `Value := 0'; Value is a 6-byte Real. TP3's layout is
  4. measured in CALC-PORT.md against the cells holding 1, 2, 3, 4, 5:
  5. value = (1 + N/2^39) * 2^(E-129)
  6. byte 0 = E biased by 129, bytes 1..5 = N little-endian, sign in bit 7 of
  7. byte 5, all-zero = 0.0.
  8. Only compile-time ordinal constants and 6-byte copies are accepted; real
  9. arithmetic/formatting is a later stage and is refused loudly. The .out
  10. checks the fields A and B on either side of V (the store is six bytes, not
  11. more), and tests/check_realconst.py asserts the six bytes themselves
  12. against the measured table. }
  13. type
  14. Cell = record
  15. V : real;
  16. A, B : integer;
  17. end;
  18. var
  19. g : array [1..2, 1..3] of Cell;
  20. i, j : integer;
  21. begin
  22. with g[2,3] do
  23. begin
  24. V := 0;
  25. A := 11;
  26. B := 12
  27. end;
  28. with g[2,3] do
  29. V := 1;
  30. i := 2;
  31. j := 3;
  32. with g[i,j] do
  33. V := 1; (* the DI form: C6 45 <off> <byte> *)
  34. with g[2,3] do
  35. V := 2;
  36. with g[2,3] do
  37. V := 3;
  38. with g[2,3] do
  39. V := 5;
  40. with g[1,1] do
  41. V := 3;
  42. with g[i,j] do
  43. V := g[1,1].V; (* 6-byte copy, destination through DI *)
  44. with g[2,3] do
  45. A := A + B;
  46. writeln (g[2,3].A);
  47. writeln (g[1,1].A)
  48. end.