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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#
#
# Nimrod's Runtime Library
# (c) Copyright 2006 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# 64 bit integers for platforms that don't have those
type
IInt64 = tuple[lo, hi: int32]
proc cmpI64(x, y: IInt64): int32 {.compilerproc.} =
result = x.hi -% y.hi
if result == 0: result = x.lo -% y.lo
proc addI64(x, y: IInt64): IInt64 {.compilerproc.} =
result = x
result.lo = result.lo +% y.lo
result.hi = result.hi +% y.hi
if y.lo > 0 and result.lo < y.lo:
inc(result.hi)
elif y.lo < 0 and result.lo > y.lo:
dec(result.hi)
proc subI64(x, y: IInt64): IInt64 {.compilerproc.} =
result = x
result.lo = result.lo -% y.lo
result.hi = result.hi -% y.hi
if y.lo > 0 and result.lo < y.lo:
inc(result.hi)
elif y.lo < 0 and result.lo > y.lo:
dec(result.hi)
proc mulI64(x, y: IInt64): IInt64 {.compilerproc.} =
result.lo = x.lo *% y.lo
result.hi = y.hi *% y.hi
if y.lo > 0 and result.lo < y.lo:
inc(result.hi)
elif y.lo < 0 and result.lo > y.lo:
dec(result.hi)
proc divI64(x, y: IInt64): IInt64 {.compilerproc.} =
# XXX: to implement
proc modI64(x, y: IInt64): IInt64 {.compilerproc.} =
# XXX: to implement
proc bitandI64(x, y: IInt64): IInt64 {.compilerproc.} =
result.hi = x.hi and y.hi
result.lo = x.lo and y.lo
proc bitorI64(x, y: IInt64): IInt64 {.compilerproc.} =
result.hi = x.hi or y.hi
result.lo = x.lo or y.lo
proc bitxorI64(x, y: IInt64): IInt64 {.compilerproc.} =
result.hi = x.hi xor y.hi
result.lo = x.lo xor y.lo
proc bitnotI64(x: IInt64): IInt64 {.compilerproc.} =
result.lo = not x.lo
result.hi = not x.hi
proc shlI64(x, y: IInt64): IInt64 {.compilerproc.} =
# XXX: to implement
proc shrI64(x, y: IInt64): IInt64 {.compilerproc.} =
# XXX: to implement
|