summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw9145.pp
blob: 8c6832f2a6eef72f49b4458d603c7ff70daae892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ %norun }

program main;
{$mode objfpc}
uses
  ctypes;

const
  // CoProcessor registers
  DIV_CR				    : pcuint16 = pointer($04000280);
  DIV_NUMERATOR64		: pcint64  = pointer($04000290);
  DIV_DENOMINATOR32	: pcint32  = pointer($04000298);
  DIV_RESULT32		  : pcint32  = pointer($040002A0);
  DIV_64_32 = 1;
  DIV_BUSY	= (1 shl 15);

function mydivf32(num: cint32; den: cint32): cint32; inline;
begin
	DIV_CR^ := DIV_64_32;
	while (DIV_CR^ and DIV_BUSY) <> 0 do;
	DIV_NUMERATOR64^ := cint64(num) shl 12;
  DIV_DENOMINATOR32^ := den;
	while (DIV_CR^ and DIV_BUSY) <> 0 do;
	mydivf32 := DIV_RESULT32^;
end;

var
  a: cint32;
begin
  a := mydivf32(10, 2);
end.