system.pp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. unit system;
  2. {$mode objfpc}
  3. interface
  4. Type
  5. dword = longword;
  6. integer = smallint;
  7. jmp_buf = packed record
  8. f,a,b,c,e,d,l,h,ixlo,ixhi,iylo,iyhi,splo,sphi,pclo,pchi : byte;
  9. end;
  10. pjmp_buf = ^jmp_buf;
  11. PExceptAddr = ^TExceptAddr;
  12. TExceptAddr = record
  13. end;
  14. PGuid = ^TGuid;
  15. TGuid = packed record
  16. case integer of
  17. 1 : (
  18. Data1 : DWord;
  19. Data2 : word;
  20. Data3 : word;
  21. Data4 : array[0..7] of byte;
  22. );
  23. 2 : (
  24. D1 : DWord;
  25. D2 : word;
  26. D3 : word;
  27. D4 : array[0..7] of byte;
  28. );
  29. 3 : ( { uuid fields according to RFC4122 }
  30. time_low : dword; // The low field of the timestamp
  31. time_mid : word; // The middle field of the timestamp
  32. time_hi_and_version : word; // The high field of the timestamp multiplexed with the version number
  33. clock_seq_hi_and_reserved : byte; // The high field of the clock sequence multiplexed with the variant
  34. clock_seq_low : byte; // The low field of the clock sequence
  35. node : array[0..5] of byte; // The spatially unique node identifier
  36. );
  37. end;
  38. HRESULT = Byte;
  39. TTypeKind = (tkUnknown,tkInteger,tkChar,tkEnumeration,tkFloat,
  40. tkSet,tkMethod,tkSString,tkLString,tkAString,
  41. tkWString,tkVariant,tkArray,tkRecord,tkInterface,
  42. tkClass,tkObject,tkWChar,tkBool,tkInt64,tkQWord,
  43. tkDynArray,tkInterfaceRaw,tkProcVar,tkUString,tkUChar,
  44. tkHelper,tkFile,tkClassRef,tkPointer);
  45. procedure fpc_InitializeUnits;compilerproc;
  46. Procedure fpc_do_exit;compilerproc;
  47. procedure PrintChar(Ch: Char);
  48. procedure PrintLn;
  49. procedure PrintHexDigit(const d: byte);
  50. procedure PrintHexByte(const b: byte);
  51. procedure PrintHexWord(const w: word);
  52. implementation
  53. var
  54. save_iy: Word; public name 'FPC_SAVE_IY';
  55. procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;
  56. begin
  57. end;
  58. Procedure fpc_do_exit;[Public,Alias:'FPC_DO_EXIT']; compilerproc;
  59. begin
  60. repeat
  61. until false;
  62. end;
  63. procedure PrintChar(Ch: Char);
  64. begin
  65. asm
  66. ld iy,(save_iy)
  67. ld a, 2
  68. push ix
  69. call 5633
  70. pop ix
  71. ld a, (Ch)
  72. push ix
  73. rst 16
  74. pop ix
  75. ld (save_iy),iy
  76. end;
  77. end;
  78. procedure PrintLn;
  79. begin
  80. PrintChar(#13);
  81. end;
  82. procedure PrintHexDigit(const d: byte);
  83. begin
  84. { the code generator is still to broken to compile this, so we do it in a stupid way }
  85. { if (d >= 0) or (d <= 9) then
  86. PrintChar(Char(d + Ord('0')))
  87. else if (d >= 10) and (d <= 15) then
  88. PrintChar(Char(d + (Ord('A') - 10)));}
  89. if d=0 then
  90. PrintChar('0')
  91. else if d=1 then
  92. PrintChar('1')
  93. else if d=2 then
  94. PrintChar('2')
  95. else if d=3 then
  96. PrintChar('3')
  97. else if d=4 then
  98. PrintChar('4')
  99. else if d=5 then
  100. PrintChar('5')
  101. else if d=6 then
  102. PrintChar('6')
  103. else if d=7 then
  104. PrintChar('7')
  105. else if d=8 then
  106. PrintChar('8')
  107. else if d=9 then
  108. PrintChar('9')
  109. else if d=10 then
  110. PrintChar('A')
  111. else if d=11 then
  112. PrintChar('B')
  113. else if d=12 then
  114. PrintChar('C')
  115. else if d=13 then
  116. PrintChar('D')
  117. else if d=14 then
  118. PrintChar('E')
  119. else if d=15 then
  120. PrintChar('F')
  121. else
  122. PrintChar('?');
  123. end;
  124. procedure PrintHexByte(const b: byte);
  125. begin
  126. PrintHexDigit(b shr 4);
  127. PrintHexDigit(b and $F);
  128. end;
  129. procedure PrintHexWord(const w: word);
  130. begin
  131. PrintHexByte(Byte(w shr 8));
  132. PrintHexByte(Byte(w));
  133. end;
  134. end.