m68k.inc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by Carl-Eric Codere,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {****************************************************************************
  13. m68k.inc : Processor dependent implementation of system unit
  14. For Motorola 680x0 Processor.
  15. *****************************************************************************}
  16. {****************************************************************************}
  17. { Credit where credit is due: }
  18. { -Some of the copy routines taken from the Atari dlib source code: }
  19. { Dale Schumacher (alias: Dalnefre') [email protected] }
  20. { 399 Beacon Ave. St. Paul, MN 55104,USA }
  21. { -Some of the routines taken from the freeware ATARI Sozobon C compiler }
  22. { 1988 by Sozobon, Limited. Author: Johann Ruegg (freeware) }
  23. { Thanks to all these people wherever they maybe today! }
  24. {****************************************************************************}
  25. { Don't call the following routines directly. }
  26. Procedure Hlt;[public,alias: 'HALT_ERROR'];
  27. { called by code generator on run-time errors. }
  28. { on entry contains d0 = error code. }
  29. var
  30. b:byte; { only byte is used... }
  31. begin
  32. asm
  33. move.b d0,b
  34. end;
  35. HandleError(b);
  36. end;
  37. Procedure FillChar(var x; count: longint; value: byte);
  38. begin
  39. asm
  40. move.l 8(a6), a0 { destination }
  41. move.l 12(a6), d1 { number of bytes to fill }
  42. move.b 16(a6),d0 { fill data }
  43. cmpi.l #65535, d1 { check, if this is a word move }
  44. ble @LMEMSET3 { use fast dbra mode }
  45. bra @LMEMSET2
  46. @LMEMSET1:
  47. move.b d0,(a0)+
  48. @LMEMSET2:
  49. subq.l #1,d1
  50. cmp.b #-1,d1
  51. bne @LMEMSET1
  52. bra @LMEMSET5 { finished slow mode , exit }
  53. @LMEMSET4: { fast loop mode section 68010+ }
  54. move.b d0,(a0)+
  55. @LMEMSET3:
  56. dbra d1,@LMEMSET4
  57. @LMEMSET5:
  58. end ['d0','d1','a0'];
  59. end;
  60. Procedure FillObject(var x; count: longint; value: byte);
  61. begin
  62. asm
  63. move.l 8(a6), a0 { destination }
  64. move.l 12(a6), d1 { number of bytes to fill }
  65. move.w 16(a6),d0 { fill data }
  66. cmp.l #65535, d1 { check, if this is a word move }
  67. ble @LMEMSET3 { use fast dbra mode }
  68. bra @LMEMSET2
  69. @LMEMSET1:
  70. move.b d0,(a0)+
  71. @LMEMSET2:
  72. subq.l #1,d1
  73. cmp.b #-1,d1
  74. bne @LMEMSET1
  75. bra @LMEMSET5 { finished slow mode , exit }
  76. @LMEMSET4: { fast loop mode section 68010+ }
  77. move.b d0,(a0)+
  78. @LMEMSET3:
  79. dbra d1,@LMEMSET4
  80. @LMEMSET5:
  81. end ['d0','d1','a0'];
  82. end;
  83. procedure int_help_constructor;
  84. begin
  85. asm
  86. XDEF HELP_CONSTRUCTOR
  87. { Entry without preamble, since we need the ESP of the
  88. constructor }
  89. { Stack (relative to %ebp):
  90. 12 Self
  91. 8 VMT-Address
  92. 4 main programm-Addr
  93. 0 %ebp
  94. }
  95. { do we have to initialize self }
  96. { we just need to check for zero }
  97. move.l a5,d0
  98. tst.l d0 { set flags }
  99. bne @LHC_4
  100. { get memory, but save register first }
  101. { temporary variable }
  102. subq.l #4,sp
  103. move.l sp,a5
  104. { Save Registers }
  105. movem.l d0-a7,-(sp)
  106. { Memory size }
  107. move.l 8(a6),a0
  108. move.l (a0),-(sp)
  109. { push method pointer }
  110. move.l a5,-(sp)
  111. jsr GETMEM
  112. { Restore all registers in the correct order }
  113. movem.l (sp)+,d0-a7
  114. { Memory size to a5 }
  115. move.l (a5),a5
  116. add.l #4,sp
  117. { If no memory available : fail() }
  118. move.l a5,d0
  119. tst.l d0 { set flags for a5 }
  120. beq @LHC_5
  121. { init self for the constructor }
  122. move.l a5,12(a6)
  123. @LHC_4:
  124. { is there a VMT address ? }
  125. move.l 8(a6),d0
  126. or.l d0,d0
  127. bne @LHC_7
  128. { In case the constructor doesn't do anything, the Zero-Flag }
  129. { can't be put, because this calls Fail() }
  130. add.l #1,d0
  131. rts
  132. @LHC_7:
  133. { set zero inside the object }
  134. { Save Registers }
  135. movem.l d0-a7,-(sp)
  136. move.w #0,-(sp)
  137. move.l 8(a6),a0
  138. move.l (a0),-(sp)
  139. move.l a5,-(sp)
  140. { }
  141. jsr FILLOBJECT
  142. { Restore all registers in the correct order }
  143. movem.l (sp)+,d0-a7
  144. { set the VMT address for the new created object }
  145. move.l 8(a6),d0
  146. move.l d0,(a5)
  147. or.l d0,d0
  148. @LHC_5:
  149. rts
  150. end;
  151. end;
  152. procedure help_fail;
  153. begin
  154. asm
  155. end;
  156. end;
  157. procedure int_help_destructor;
  158. begin
  159. asm
  160. { Stack (relative to %ebp):
  161. 12 Self
  162. 8 VMT-Address
  163. 4 Main program-Addr
  164. 0 %ebp
  165. }
  166. { temporary Variable }
  167. XDEF HELP_DESTRUCTOR
  168. subq.l #4,sp
  169. move.l sp,d6
  170. { Save Registers }
  171. movem.l d0-a7,-(sp)
  172. move.l 8(a6),d0 { Get the address of the vmt }
  173. or.l d0,d0 { Check if there is a vmt }
  174. beq @LHD_3
  175. { Yes, get size from SELF! }
  176. move.l 12(a6),a0
  177. { get VMT-pointer (from Self) to %ebx }
  178. move.l (a0),a1
  179. { And put size on the Stack }
  180. move.l (a1),-(sp)
  181. { SELF }
  182. { I think for precaution }
  183. { that we should clear the VMT here }
  184. clr.l (a0)
  185. { get address of local variable into }
  186. { address register }
  187. move.l d6,a1
  188. move.l a0,(a1)
  189. move.l a1,-(sp)
  190. jsr FREEMEM
  191. @LHD_3:
  192. { Restore all registers in the correct order }
  193. movem.l (sp)+,d0-a7
  194. add.l #4,sp
  195. rts
  196. end;
  197. end;
  198. procedure new_class;assembler;
  199. asm
  200. XDEF NEW_CLASS
  201. { create class ? }
  202. move.l 8(a6), d0
  203. tst.l d0
  204. { check for nil... }
  205. beq @NEW_CLASS1
  206. { a5 contains vmt }
  207. move.l a5,-(sp)
  208. { call newinstance (class method!) }
  209. jsr 16(a5)
  210. { new instance returns a pointer to the new created }
  211. { instance in d0 }
  212. { load a5 and insert self }
  213. move.l d0,8(a6)
  214. move.l d0,a5
  215. bra @end
  216. @NEW_CLASS1:
  217. move.l a5,8(a6)
  218. @end:
  219. end;
  220. procedure dispose_class;assembler;
  221. asm
  222. XDEF DISPOSE_CLASS
  223. { destroy class ? }
  224. move.l 8(a6),d0
  225. { save self }
  226. move.l a5,8(a6)
  227. tst.l d0
  228. beq @DISPOSE_CLASS
  229. { no inherited call }
  230. move.l (a5),d0
  231. { push self }
  232. move.l a5,-(sp)
  233. { call freeinstance }
  234. move.l d0,a0
  235. jsr 20(a0)
  236. @DISPOSE_CLASS:
  237. { load self }
  238. move.l 8(a6),a5
  239. end;
  240. { checks for a correct vmt pointer }
  241. procedure co;assembler;
  242. { ON ENTRY: a0 -> Pointer to the VMT }
  243. { Nota: All registers must be preserved including }
  244. { A0 itself! }
  245. asm
  246. XDEF CHECK_OBJECT
  247. move.l d0,-(sp)
  248. tst.l a0
  249. { z flag set if zero }
  250. beq @co_re
  251. move.l (a0),d0
  252. add.l 4(a0),d0
  253. bne @co_re
  254. bra @end
  255. @co_re:
  256. move.l (sp)+,d0
  257. move.b #210,d0
  258. jsr HALT_ERROR
  259. @end:
  260. move.l (sp)+,d0
  261. end;
  262. function get_addr(BP : longint) : longint;
  263. begin
  264. asm
  265. move.l BP,a0
  266. cmp.l #0,a0
  267. beq @Lnul_address
  268. move.l 4(a0),a0
  269. @Lnul_address:
  270. move.l a0,@RESULT
  271. end ['a0'];
  272. end;
  273. function get_next_frame(bp : longint) : longint;
  274. begin
  275. asm
  276. move.l bp,a0
  277. cmp.l #0,a0
  278. beq @Lnul_frame
  279. move.l (a0),a0
  280. @Lnul_frame:
  281. move.l a0,@RESULT
  282. end ['a0'];
  283. end;
  284. Procedure HandleError (Errno : longint);[alias : 'handleerror'];
  285. {
  286. Procedure to handle internal errors, i.e. not user-invoked errors
  287. Internal function should ALWAYS call HandleError instead of RunError.
  288. }
  289. function get_addr : pointer;
  290. begin
  291. asm
  292. move.l (a6),a0
  293. move.l 4(a0),a0
  294. move.l a0,@RESULT
  295. end ['a0'];
  296. end;
  297. function get_error_bp : longint;
  298. begin
  299. asm
  300. { get base pointer of error }
  301. move.l (a6),d0
  302. move.l d0,@RESULT
  303. end ['d0'];
  304. end;
  305. begin
  306. If ErrorProc<>Nil then
  307. TErrorProc (ErrorProc)(Errno,get_addr);
  308. errorcode:=Errno;
  309. exitcode:=Errno;
  310. erroraddr:=Get_addr;
  311. DoError := TRUE;
  312. errorbase:=get_error_bp;
  313. halt(errorcode);
  314. end;
  315. procedure runerror(w : word);
  316. function get_addr : longint;
  317. begin
  318. asm
  319. move.l (a6),a0
  320. move.l 4(a0),a0
  321. move.l a0,@RESULT
  322. end ['a0'];
  323. end;
  324. function get_error_bp : longint;
  325. begin
  326. asm
  327. { get base pointer of error }
  328. move.l (a6),d0
  329. move.l d0,@RESULT
  330. end ['d0'];
  331. end;
  332. begin
  333. errorcode:=w;
  334. exitcode:=w;
  335. erroraddr:=pointer(get_addr);
  336. DoError:=True;
  337. ErrorBase:=get_error_bp;
  338. halt(byte(errorcode));
  339. end;
  340. procedure io1(addr : longint);[public,alias: 'IOCHECK'];
  341. var
  342. l : longint;
  343. begin
  344. { Since IOCHECK is called directly and only later the optimiser }
  345. { Maybe also save global registers }
  346. asm
  347. movem.l d0-a7,-(sp)
  348. end;
  349. l:=ioresult;
  350. if l<>0 then
  351. begin
  352. writeln('IO-Error ',l,' at 0x',HexStr(addr,8));
  353. halt(byte(l));
  354. end;
  355. asm
  356. { the register are put back in the correct order }
  357. movem.l (sp)+,d0-a7
  358. end;
  359. end;
  360. procedure re_overflow;[public,alias: 'RE_OVERFLOW'];
  361. var
  362. addr : longint;
  363. begin
  364. { Overflow was shortly before the return address }
  365. asm
  366. move.l 4(a6),d0
  367. move.l d0,addr
  368. end;
  369. writeln('Overflow at 0x',HexStr(addr,8));
  370. HandleError(215);
  371. end;
  372. { procedure strcopy(dstr,sstr : pointer;len : longint);[public,alias: 'STRCOPY'];}
  373. procedure strcopy; assembler;
  374. {---------------------------------------------------}
  375. { Low-level routine to copy a string to another }
  376. { string with maximum length. Never call directly! }
  377. { On Entry: }
  378. { a1.l = string to copy to }
  379. { a0.l = source string }
  380. { d0.l = maximum length of copy }
  381. { registers destroyed: a0,a1,d0,d1 }
  382. {---------------------------------------------------}
  383. asm
  384. XDEF STRCOPY
  385. { move.l 12(a6),a0
  386. move.l 16(a6),a1
  387. move.l 8(a6),d1 }
  388. move.l d0,d1
  389. move.b (a0)+,d0 { Get source length }
  390. and.w #$ff,d0
  391. cmp.w d1,d0 { This is a signed comparison! }
  392. ble @LM4
  393. move.b d1,d0 { If longer than maximum size of target, cut
  394. source length }
  395. @LM4:
  396. andi.l #$ff,d0 { zero extend d0-byte }
  397. move.l d0,d1 { save length to copy }
  398. move.b d0,(a1)+ { save new length }
  399. { Check if copying length is zero - if so then }
  400. { exit without copying anything. }
  401. tst.b d1
  402. beq @Lend
  403. bra @LMSTRCOPY55
  404. @LMSTRCOPY56: { 68010 Fast loop mode }
  405. move.b (a0)+,(a1)+
  406. @LMSTRCOPY55:
  407. dbra d1,@LMSTRCOPY56
  408. @Lend:
  409. end;
  410. { Concatenate Strings }
  411. { PARAMETERS ARE REVERSED COMPARED TO NORMAL! }
  412. { therefore online assembler may not parse the params as normal }
  413. procedure strconcat(s1,s2 : pointer);[public,alias: 'STRCONCAT'];
  414. begin
  415. asm
  416. move.b #255,d0
  417. move.l s1,a0 { a0 = destination }
  418. move.l s2,a1 { a1 = source }
  419. sub.b (a0),d0 { copyl:= 255 -length(s1) }
  420. move.b (a1),d6
  421. and.w #$ff,d0 { Sign flags are checked! }
  422. and.w #$ff,d6
  423. cmp.w d6,d0 { if copyl > length(s2) then }
  424. ble @Lcontinue
  425. move.b (a1),d0 { copyl:=length(s2) }
  426. @Lcontinue:
  427. move.b (a0),d6
  428. and.l #$ff,d6
  429. lea 1(a0,d6),a0 { s1[length(s1)+1] }
  430. add.l #1,a1 { s2[1] }
  431. move.b d0,d6
  432. { Check if copying length is zero - if so then }
  433. { exit without copying anything. }
  434. tst.b d6
  435. beq @Lend
  436. bra @ALoop
  437. @Loop:
  438. move.b (a1)+,(a0)+ { s1[i] := s2[i]; }
  439. @ALoop:
  440. dbra d6,@Loop
  441. move.l s1,a0
  442. add.b d0,(a0) { change to new string length }
  443. @Lend:
  444. end ['d0','d1','a0','a1','d6'];
  445. end;
  446. { Compares strings }
  447. { DO NOT CALL directly. }
  448. { a0 = pointer to first string to compare }
  449. { a1 = pointer to second string to compare }
  450. { ALL FLAGS are set appropriately. }
  451. { ZF = strings are equal }
  452. { REGISTERS DESTROYED: a0, a1, d0, d1, d6 }
  453. procedure strcmp; assembler;
  454. asm
  455. XDEF STRCMP
  456. move.b (a0)+,d0 { Get length of first string }
  457. move.b (a1)+,d6 { Get length of 2nd string }
  458. move.b d6,d1 { Save length of string for final compare }
  459. cmp.b d0,d6 { Get shortest string length }
  460. ble @LSTRCONCAT1
  461. move.b d0,d6 { Set length to shortest string }
  462. @LSTRCONCAT1:
  463. tst.b d6 { Both strings have a length of zero, exit }
  464. beq @LSTRCONCAT2
  465. andi.l #$ff,d6
  466. subq.l #1,d6 { subtract first attempt }
  467. { if value is -1 then don't loop and just compare lengths of }
  468. { both strings before exiting. }
  469. bmi @LSTRCONCAT2
  470. or.l d0,d0 { Make sure to set Zerfo flag to 0 }
  471. @LSTRCONCAT5:
  472. { Workaroung for GAS v.134 bug }
  473. { old: cmp.b (a1)+,(a0)+ }
  474. cmpm.b (a1)+,(a0)+
  475. @LSTRCONCAT4:
  476. dbne d6,@LSTRCONCAT5 { Repeat until not equal }
  477. bne @LSTRCONCAT3
  478. @LSTRCONCAT2:
  479. { If length of both string are equal }
  480. { Then set zero flag }
  481. cmp.b d1,d0 { Compare length - set flag if equal length strings }
  482. @LSTRCONCAT3:
  483. end;
  484. Function strpas(p: pchar): string;
  485. { only 255 first characters are actually copied. }
  486. var
  487. counter : byte;
  488. str: string;
  489. Begin
  490. counter := 0;
  491. str := '';
  492. while (ord(p[counter]) <> 0) and (counter < 255) do
  493. begin
  494. counter:=counter+1;
  495. str[counter] := char(p[counter-1]);
  496. end;
  497. str[0] := char(counter);
  498. strpas := str;
  499. end;
  500. function strlen(p : pchar) : longint;
  501. var
  502. counter : longint;
  503. Begin
  504. counter := 0;
  505. repeat
  506. counter:=counter+1;
  507. until ord(p[counter]) = 0;
  508. strlen := counter;
  509. end;
  510. procedure move(var source;var dest;count : longint);
  511. { base pointer+8 = source }
  512. { base pointer+12 = destination }
  513. { base pointer+16 = number of bytes to move}
  514. begin
  515. asm
  516. clr.l d0
  517. move.l 16(a6),d0 { number of bytes }
  518. @LMOVE0:
  519. move.l 12(a6),a1 { destination }
  520. move.l 8(a6),a0 { source }
  521. cmpi.l #65535, d0 { check, if this is a word move }
  522. ble @LMEMSET00 { use fast dbra mode 68010+ }
  523. cmp.l a0,a1 { check copy direction }
  524. bls @LMOVE4
  525. add.l d0,a0 { move pointers to end }
  526. add.l d0,a1
  527. bra @LMOVE2
  528. @LMOVE1:
  529. move.b -(a0),-(a1) { (s < d) copy loop }
  530. @LMOVE2:
  531. subq.l #1,d0
  532. cmpi.l #-1,d0
  533. bne @LMOVE1
  534. bra @LMOVE5
  535. @LMOVE3:
  536. move.b (a0)+,(a1)+ { (s >= d) copy loop }
  537. @LMOVE4:
  538. subq.l #1,d0
  539. cmpi.l #-1,d0
  540. bne @LMOVE3
  541. bra @LMOVE5
  542. @LMEMSET00: { use fast loop mode 68010+ }
  543. cmp.l a0,a1 { check copy direction }
  544. bls @LMOVE04
  545. add.l d0,a0 { move pointers to end }
  546. add.l d0,a1
  547. bra @LMOVE02
  548. @LMOVE01:
  549. move.b -(a0),-(a1) { (s < d) copy loop }
  550. @LMOVE02:
  551. dbra d0,@LMOVE01
  552. bra @LMOVE5
  553. @LMOVE03:
  554. move.b (a0)+,(a1)+ { (s >= d) copy loop }
  555. @LMOVE04:
  556. dbra d0,@LMOVE03
  557. { end fast loop mode }
  558. @LMOVE5:
  559. end ['d0','a0','a1'];
  560. end;
  561. procedure fillword(var x;count : longint;value : word);
  562. begin
  563. asm
  564. move.l 8(a6), a0 { destination }
  565. move.l 12(a6), d1 { number of bytes to fill }
  566. move.w 16(a6),d0 { fill data }
  567. bra @LMEMSET21
  568. @LMEMSET11:
  569. move.w d0,(a0)+
  570. @LMEMSET21:
  571. subq.l #1,d1
  572. cmp.b #-1,d1
  573. bne @LMEMSET11
  574. end ['d0','d1','a0'];
  575. end;
  576. function abs(l : longint) : longint;
  577. begin
  578. asm
  579. move.l 8(a6),d0
  580. tst.l d0
  581. bpl @LMABS1
  582. neg.l d0
  583. @LMABS1:
  584. move.l d0,@RESULT
  585. end ['d0'];
  586. end;
  587. function odd(l : longint) : boolean;
  588. begin
  589. if (l and $01) = $01 then
  590. odd := TRUE
  591. else
  592. odd := FALSE;
  593. end;
  594. function sqr(l : longint) : longint;
  595. begin
  596. sqr := l*l;
  597. end;
  598. procedure int_str(l : longint;var s : string);
  599. var
  600. value: longint;
  601. negative: boolean;
  602. begin
  603. negative := false;
  604. s:='';
  605. { Workaround: }
  606. if l=$80000000 then
  607. begin
  608. s:='-2147483648';
  609. exit;
  610. end;
  611. { handle case where l = 0 }
  612. if l = 0 then
  613. begin
  614. s:='0';
  615. exit;
  616. end;
  617. If l < 0 then
  618. begin
  619. negative := true;
  620. value:=abs(l);
  621. end
  622. else
  623. value:=l;
  624. { handle non-zero case }
  625. while value>0 do
  626. begin
  627. s:=char((value mod 10)+ord('0'))+s;
  628. value := value div 10;
  629. end;
  630. if negative then
  631. s := '-' + s;
  632. end;
  633. {$IFNDEF NEW_READWRITE}
  634. procedure f1;[public,alias: 'FLUSH_STDOUT'];
  635. begin
  636. asm
  637. { Save Registers }
  638. movem.l d0-a7,-(sp)
  639. end;
  640. FileFunc(textrec(output).flushfunc)(textrec(output));
  641. asm
  642. { Restore all registers in the correct order }
  643. movem.l (sp)+,d0-a7
  644. end;
  645. end;
  646. {$ENDIF NEW_READWRITE}
  647. Function Sptr : Longint;
  648. begin
  649. asm
  650. move.l sp,d0
  651. add.l #8,d0
  652. move.l d0,@RESULT
  653. end ['d0'];
  654. end;
  655. Procedure BoundsCheck;assembler;
  656. { called by code generator with R+ state to }
  657. { determine if a range check occured. }
  658. { Only in 68000 mode, in 68020 mode this is }
  659. { inline. }
  660. { On Entry: }
  661. { A1 = address contaning min and max indexes }
  662. { D0 = value of current index to check. }
  663. asm
  664. XDEF RE_BOUNDS_CHECK
  665. cmp.l (A1),D0 { lower bound ... }
  666. bmi @rebounderr { is index lower ... }
  667. add.l #4,A1
  668. cmp.l (A1),D0
  669. bmi @reboundend
  670. beq @reboundend
  671. @rebounderr:
  672. move.l #201,d0
  673. jsr HALT_ERROR
  674. @reboundend:
  675. end;
  676. {
  677. $Log$
  678. Revision 1.10 1998-08-17 12:26:04 carl
  679. + simple cleanup of comments
  680. Revision 1.9 1998/07/30 13:26:14 michael
  681. + Added support for ErrorProc variable. All internal functions are required
  682. to call HandleError instead of runerror from now on.
  683. This is necessary for exception support.
  684. Revision 1.8 1998/07/10 11:02:41 peter
  685. * support_fixed, becuase fixed is not 100% yet for the m68k
  686. Revision 1.7 1998/07/02 12:20:58 carl
  687. + Io-Error and overflow print erroraddr in hex now
  688. Revision 1.6 1998/07/01 14:25:57 carl
  689. * strconcat was copying one byte too much
  690. * strcopy bugfix was using signed comparison
  691. + STRCOPY uses register calling conventions
  692. * FillChar bugfix was loading a word instead of a byte
  693. Revision 1.2 1998/03/27 23:48:06 carl
  694. * bugfix of STRCONCAT alignment problem
  695. Revision 1.18 1998/03/02 04:17:24 carl
  696. * problem with CHECK_OBJECT fixed, will probably only work with
  697. GNU tools, as the VMT pointer is an .lcomm and might not be
  698. zeroed automatically by other loaders.
  699. * CHECK_OBJECT was not jumping on right condition
  700. Revision 1.17 1998/02/23 02:26:06 carl
  701. * bugfix to make it link without problems
  702. Revision 1.13 1998/02/06 16:35:35 carl
  703. * oops commited wrong file
  704. Revision 1.11 1998/01/26 12:01:32 michael
  705. + Added log at the end
  706. Working file: rtl/m68k/m68k.inc
  707. description:
  708. ----------------------------
  709. revision 1.10
  710. date: 1998/01/19 10:21:36; author: michael; state: Exp; lines: +1 -12
  711. * moved Fillchar t(..,char) to system.inc
  712. ----------------------------
  713. revision 1.9
  714. date: 1998/01/13 03:47:39; author: carl; state: Exp; lines: +3 -3
  715. * bugfix of BoundsCheck invalid opcodes
  716. ----------------------------
  717. revision 1.8
  718. date: 1998/01/13 03:24:58; author: carl; state: Exp; lines: +2 -2
  719. * moveq.l #201 bugfix (This is of course an impossible opcode)
  720. ----------------------------
  721. revision 1.7
  722. date: 1998/01/12 15:24:47; author: carl; state: Exp; lines: +1 -20
  723. * bugfix, a function was being duplicated.
  724. ----------------------------
  725. revision 1.6
  726. date: 1998/01/12 03:40:11; author: carl; state: Exp; lines: +2 -2
  727. * bugfix of RE_OVERFLOW, now gives out a runerror(215)
  728. ----------------------------
  729. revision 1.5
  730. date: 1998/01/05 00:31:43; author: carl; state: Exp; lines: +206 -119
  731. * Bugfix of syntax errors
  732. ----------------------------
  733. revision 1.4
  734. date: 1998/01/01 16:50:16; author: michael; state: Exp; lines: +1 -21
  735. - Moved Do_exit to system.inc. Now processor independent.
  736. ----------------------------
  737. revision 1.3
  738. date: 1997/12/10 12:15:05; author: michael; state: Exp; lines: +2 -2
  739. * changed dateifunc to FileFunc.
  740. ----------------------------
  741. revision 1.2
  742. date: 1997/12/01 12:37:21; author: michael; state: Exp; lines: +14 -0
  743. + added copyright reference in header.
  744. ----------------------------
  745. revision 1.1
  746. date: 1997/11/27 08:33:48; author: michael; state: Exp;
  747. Initial revision
  748. ----------------------------
  749. revision 1.1.1.1
  750. date: 1997/11/27 08:33:48; author: michael; state: Exp; lines: +0 -0
  751. FPC RTL CVS start
  752. =============================================================================
  753. }