ack/lang/a68s/aem/cmpdum.p
1988-10-04 10:56:50 +00:00

138 lines
4.8 KiB
OpenEdge ABL

00100 (*+02() (*$T-*) (*$D+*) (*$W-*) (*$L-*) ()+02*)
00105 PROGRAM COMPARE(F1,F2,INIT(*+02(),OUTPUT()+02*));
00110 CONST SZWORD = (*+12() 2 ()+12*) (*+13() 4 ()+13*);
00112 HOFFSET = (*-02() 4 ()-02*) (*+02() (*+19() 6 ()+19*) (*-19() 8 ()-19*) ()+02*)
00113 (* HOFFSET IS THE AMOUNT THE HEAP HAS BEEN MOVED UP *)
00120 TYPE ADDRINT = (*-02()INTEGER()-02*)(*+02()LONG()+02*);
00130 LOADFILE = FILE OF ADDRINT;
00140 VAR F1,F2 : LOADFILE;
00150 INIT : LOADFILE;
00160 GLOBALLENGTH,HEAPSTART,HEAPLENGTH,DUMMY : ADDRINT;
00169 (*-19()
00170 PROCEDURE COPY(LENGTH : ADDRINT);
00180 VAR I,VALUE : INTEGER;
00190 D : RECORD INT,MASK : INTEGER END;
00200 BEGIN
00210 FOR I := 1 TO LENGTH DO
00220 BEGIN
00230 READ(F1,D.INT);
00240 READ(F2,VALUE);
00250 D.MASK := VALUE-D.INT;
00260 IF NOT (D.MASK IN [0,HOFFSET]) THEN (*VALUE IS PART OF A PACKED RECORD AND TOP BYTE IS NOT USED*)
00270 D.MASK := 0;
00280 IF D.MASK=HOFFSET THEN (* D.INT IS A POINTER *)
00290 D.INT := D.INT-HEAPSTART;
00300 WRITE(INIT,D.INT,D.MASK)
00310 END
00320 END;
00330 ()-19*)
00350 (*+19()
00360 PROCEDURE COPY(LENGTH : ADDRINT);
00370 VAR
00380 POINTER : ADDRINT;
00390 LAST1,THIS1,THIS2 : ADDRINT; (*BECAUSE UNINTIALISED HEAP IS -32768*)
00400 DIFF : INTEGER;
00410 LSW,MSW : ADDRINT;
00425 COUNT : ADDRINT;
00000 FUNCTION WORDSREVERSED:BOOLEAN;
00000 TYPE R = RECORD
00000 CASE BOOLEAN OF
00000 TRUE: (X: ADDRINT);
00000 FALSE: (Y: INTEGER;
00000 Z: INTEGER);
00000 END;
00000 VAR V: R;
00000 BEGIN
00000 V.X := 1;
00000 WORDSREVERSED := V.Y<>1
00000 END;
00430 BEGIN
00000 IF NOT WORDSREVERSED THEN
00000 BEGIN
00435 COUNT := 1;
00440 WHILE COUNT<=LENGTH DO
00450 BEGIN
00460 READ(F1,THIS1);
00470 READ(F2,THIS2);
00475 COUNT := COUNT+1;
00480 DIFF := ABS(ABS(THIS1)-ABS(THIS2));
00490 IF DIFF IN [2,HOFFSET] THEN (* LSW OF POINTER *)
00500 BEGIN
00510 LSW := THIS1; (*CONVERT TO 32 BIT NO *)
00520 IF THIS1<0 THEN
00530 LSW := LSW+65536; (*CONVERT FROM 2'S COMP TO UNSIGNED *)
00540 READ(F1,MSW);
00550 READ(F2,DUMMY);
00555 COUNT := COUNT+1;
00560 POINTER := (MSW*65536)+LSW;
00570 POINTER := POINTER-HEAPSTART; (*MAKE POINTER RELATIVE*)
00580 WRITE(INIT,HOFFSET,POINTER);
00583 IF POINTER>HEAPLENGTH THEN
00585 WRITELN('WARNING: POINTER OUT OF RANGE',POINTER);
00590 END
00600 ELSE IF DIFF<>0 THEN
00610 BEGIN
00620 WRITELN('WARNING: UNKNOWN CHANGE IN VALUE',DIFF,' FROM',THIS1,' TO',THIS2);
00630 WRITE(INIT,0,THIS1)
00640 END
00650 ELSE
00660 WRITE(INIT,0,THIS1);
00670 END
00680 END
00000 ELSE
00000 BEGIN
00000 COUNT := 0;
00000 READ(F1,THIS1);
00000 READ(F2,THIS2);
00000 COUNT := COUNT+1;
00000 WHILE COUNT<=LENGTH DO
00000 BEGIN
00000 LAST1 := THIS1;
00000 IF COUNT<LENGTH THEN
00000 BEGIN
00000 READ(F1,THIS1);
00000 READ(F2,THIS2);
00000 END;
00000 COUNT := COUNT+1;
00000 IF THIS1=THIS2 THEN
00000 WRITE(INIT,0,LAST1)
00000 ELSE
00000 BEGIN
00000 DIFF := ABS(ABS(THIS1)-ABS(THIS2));
00000 IF DIFF IN [2,HOFFSET] THEN
00000 BEGIN
00000 LSW := THIS1;
00000 IF THIS1<0 THEN
00000 LSW := LSW+65536;
00000 POINTER := LAST1*65536+LSW-HEAPSTART;
00000 WRITE(INIT,HOFFSET,POINTER);
00000 IF POINTER>HEAPLENGTH THEN
00000 WRITELN('WARNING: POINTER OUT OF RANGE',POINTER);
00000 IF COUNT<=LENGTH THEN
00000 BEGIN
00000 READ(F1,THIS1);
00000 READ(F2,THIS2);
00000 END;
00000 COUNT := COUNT+1;
00000 END
00000 ELSE
00000 BEGIN
00000 WRITELN('WARNING: UNKNOWN CHANGE IN VALUE',DIFF,' FROM',THIS1,' TO',THIS2);
00000 WRITE(INIT,0,LAST1)
00000 END
00000 END
00000 END
00000 END;
00675 WRITELN('COPY OF LENGTH',(COUNT-1)*SZWORD); (*IN BYTES*)
00000 END;
00690 ()+19*)
00710 BEGIN(*OF COMPARE*)
00720 RESET(F1); RESET(F2); REWRITE(INIT);
00730 READ(F1,GLOBALLENGTH);WRITE(INIT,GLOBALLENGTH);
00740 READ(F1,HEAPLENGTH);WRITE(INIT,HEAPLENGTH);
00750 READ(F1,HEAPSTART);
00760 READ(F2,DUMMY);READ(F2,DUMMY);READ(F2,DUMMY);
00770 COPY(GLOBALLENGTH DIV SZWORD);
00780 COPY(HEAPLENGTH DIV SZWORD);
00790 END.