mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 15:42:25 +00:00
Port updated tests and binary snapping, with corrected Reals code, from tidy branch.
This commit is contained in:
parent
b1dc7d77e8
commit
ca2cc52a44
221 changed files with 949 additions and 550 deletions
|
|
@ -91,11 +91,51 @@ BEGIN
|
|||
(* Also need full tests for CHAR, and poossibly SYSTEM.BYTE. Here's a simple one *)
|
||||
|
||||
c := 1X; c := SYSTEM.LSH(c,2); c := SYSTEM.ROT(c,-2); ASSERT(c=1X, 93);
|
||||
b := 1; b := SYSTEM.LSH(b,2); b := SYSTEM.ROT(b,-2); ASSERT(SYSTEM.VAL(INTEGER,b)=1, 94);
|
||||
b := 1; b := SYSTEM.LSH(b,2); b := SYSTEM.ROT(b,-2); ASSERT(SYSTEM.VAL(CHAR,b)=1X, 94);
|
||||
|
||||
END Shift;
|
||||
|
||||
|
||||
PROCEDURE TestValue(v,e: LONGINT; name: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
IF v # e THEN
|
||||
Console.String(name);
|
||||
Console.String(" = ");
|
||||
Console.Int(v,1);
|
||||
Console.String(", expected ");
|
||||
Console.Int(e,1);
|
||||
Console.Ln;
|
||||
END
|
||||
END TestValue;
|
||||
|
||||
PROCEDURE IntSize;
|
||||
VAR l: LONGINT;
|
||||
BEGIN
|
||||
TestValue(MIN(SHORTINT), -80H, "MIN(SHORTINT)");
|
||||
TestValue(MAX(SHORTINT), 7FH, "MAX(SHORTINT)");
|
||||
IF SIZE(INTEGER) = 2 THEN (* 32 bit machine *)
|
||||
TestValue(MIN(INTEGER), -7FFFH - 1, "MIN(INTEGER)");
|
||||
TestValue(MAX(INTEGER), 7FFFH, "MAX(INTEGER)");
|
||||
TestValue(MIN(LONGINT), -7FFFFFFFH - 1, "MIN(LONGINT)");
|
||||
TestValue(MAX(LONGINT), 7FFFFFFFH, "MAX(LONGINT)");
|
||||
ELSIF SIZE(INTEGER) = 4 THEN (* 64 bit machine *)
|
||||
TestValue(MIN(INTEGER), -7FFFFFFFH - 1, "MIN(INTEGER)");
|
||||
TestValue(MAX(INTEGER), 7FFFFFFFH, "MAX(INTEGER)");
|
||||
(* Since we need to be compilable on 32 bit machines we cannot use
|
||||
a 64 bit constant, so use arithmetic. *)
|
||||
l := 1; l := SYSTEM.LSH(l, 63); l := l-1; (* Generate l = 7FFFFFFFFFFFFFFFH *)
|
||||
TestValue(MIN(LONGINT), -l - 1, "MIN(LONGINT)");
|
||||
TestValue(MAX(LONGINT), l, "MAX(LONGINT)");
|
||||
ELSE
|
||||
Console.String("SIZE(INTEGER) = ");
|
||||
Console.Int(SIZE(INTEGER),1);
|
||||
Console.String(", expected 2 or 4.");
|
||||
Console.Ln;
|
||||
END;
|
||||
END IntSize;
|
||||
|
||||
BEGIN
|
||||
Shift;
|
||||
IntSize;
|
||||
Console.String("Language tests successful."); Console.Ln;
|
||||
END TestLanguage.
|
||||
|
|
|
|||
|
|
@ -484,3 +484,58 @@ D3E2 sall %cl, %edx
|
|||
89D0 movl %edx, %eax
|
||||
09D8 orl %ebx, %eax
|
||||
8845E5 movb %al, -27(%ebp)
|
||||
0FB645E5 movzbl -27(%ebp), %eax
|
||||
3A45F7 cmpb -9(%ebp), %al
|
||||
740C je L52
|
||||
C7042436 movl $54, (%esp)
|
||||
E8000000 call _Platform_AssertFail
|
||||
D07DF7 sarb -9(%ebp)
|
||||
0FB745F4 movzwl -12(%ebp), %eax
|
||||
83E801 subl $1, %eax
|
||||
668945F4 movw %ax, -12(%ebp)
|
||||
66837DF4 cmpw $-7, -12(%ebp)
|
||||
0F8D19FF jge L53
|
||||
66C745F4 movw $0, -12(%ebp)
|
||||
C745EC01 movl $1, -20(%ebp)
|
||||
8B45EC movl -20(%ebp), %eax
|
||||
C1E01F sall $31, %eax
|
||||
8945EC movl %eax, -20(%ebp)
|
||||
8B45EC movl -20(%ebp), %eax
|
||||
8945E0 movl %eax, -32(%ebp)
|
||||
EB50 jmp L54
|
||||
8B45E0 movl -32(%ebp), %eax
|
||||
8945E8 movl %eax, -24(%ebp)
|
||||
66837DF4 cmpw $0, -12(%ebp)
|
||||
780F js L55
|
||||
0FBF45F4 movswl -12(%ebp), %eax
|
||||
8B55E8 movl -24(%ebp), %edx
|
||||
89C1 movl %eax, %ecx
|
||||
D3E2 sall %cl, %edx
|
||||
89D0 movl %edx, %eax
|
||||
EB0F jmp L56
|
||||
0FBF45F4 movswl -12(%ebp), %eax
|
||||
F7D8 negl %eax
|
||||
8B55E8 movl -24(%ebp), %edx
|
||||
89C1 movl %eax, %ecx
|
||||
D3FA sarl %cl, %edx
|
||||
89D0 movl %edx, %eax
|
||||
8945E8 movl %eax, -24(%ebp)
|
||||
8B45E8 movl -24(%ebp), %eax
|
||||
3B45EC cmpl -20(%ebp), %eax
|
||||
740C je L57
|
||||
C704243E movl $62, (%esp)
|
||||
E8000000 call _Platform_AssertFail
|
||||
D17DEC sarl -20(%ebp)
|
||||
0FB745F4 movzwl -12(%ebp), %eax
|
||||
83E801 subl $1, %eax
|
||||
668945F4 movw %ax, -12(%ebp)
|
||||
66837DF4 cmpw $-31, -12(%ebp)
|
||||
7DA9 jge L58
|
||||
66C745F4 movw $0, -12(%ebp)
|
||||
66C745E6 movw $1, -26(%ebp)
|
||||
0FB745E6 movzwl -26(%ebp), %eax
|
||||
0FB7C0 movzwl %ax, %eax
|
||||
C1E00F sall $15, %eax
|
||||
668945E6 movw %ax, -26(%ebp)
|
||||
0FB745E6 movzwl -26(%ebp), %eax
|
||||
668945F2 movw %ax, -14(%ebp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
# Generate mixed source and assembly code listing
|
||||
voc TestLanguage.mod -m
|
||||
$OBECOMP TestLanguage.mod -m
|
||||
./TestLanguage >result
|
||||
. ../testresult.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue