123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- {****************************************************************}
- { CODE GENERATOR TEST PROGRAM }
- {****************************************************************}
- { NODE TESTED : secondmoddiv() }
- {****************************************************************}
- { PRE-REQUISITES: secondload() }
- { secondassign() }
- { secondtypeconv() }
- {****************************************************************}
- { DEFINES: }
- { FPC = Target is FreePascal compiler }
- {****************************************************************}
- { REMARKS: }
- { }
- { }
- { }
- {****************************************************************}
- { CURRENT NODE (result): }
- { LOC_REGISTER }
- { LEFT NODE (operand) (numerator) }
- { LOC_REFERENCE / LOC_MEM }
- { LOC_REGISTER / LOC_CREGISTER }
- { RIGHT NODE (operand (denominator) }
- { ord constant node }
- { LOC_REGISTER / LOC_CREGISTER }
- { LOC_REFERENCE / LOC_MEM }
- function getlongcnt: longint;
- begin
- getlongcnt := -10;
- end;
- {$IFDEF FPC}
- function getcardinalcnt: cardinal;
- begin
- getcardinalcnt := 10;
- end;
- function getint64cnt: int64;
- begin
- getint64cnt := -10;
- end;
- {$ENDIF}
- var
- longres : longint;
- longcnt : longint;
- {$IFDEF FPC}
- cardinalres : cardinal;
- cardinalcnt : cardinal;
- int64res : int64;
- int64cnt : int64;
- {$ENDIF}
- begin
- WriteLn('------------------- LONGINT ------------------------');
- WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- longres := 24;
- longres := longres div 4;
- Write('Value should be 6...');
- if longres = 6 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- longres := 24;
- longres := longres mod 4;
- Write('Value should be 0...');
- if longres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- longres := 136;
- longcnt := -13;
- longres := longres div longcnt;
- Write('Value should be -10...');
- if longres = -10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- longres := 10101010;
- longcnt := -13;
- longres := longres mod longcnt;
- Write('Value should be 10...');
- if longres = 10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- longres := -11111111;
- longres := longres div getlongcnt;
- Write('Value should be 1111111...');
- if longres = 1111111 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- longres := -1111111;
- longres := longres mod getlongcnt;
- Write('Value should be -1...');
- if longres = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- longcnt := 2;
- longres := getlongcnt div longcnt;
- Write('Value should be -5...');
- if longres = -5 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- longcnt := 3;
- longres := getlongcnt mod longcnt;
- Write('Value should be -1...');
- if longres = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { special tests for results }
- Writeln('special numeric values tests...');
- longres := $7FFFFFFF;
- longcnt := $80000000;
- longres := longres div longcnt;
- Write('Value should be 0...');
- if longres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- longres := $7FFFFFFF;
- longcnt := $80000000;
- longres := longcnt div longres;
- Write('Value should be -1...');
- if longres = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- cardinalcnt := $80000;
- cardinalres := $12345;
- cardinalres := cardinalcnt div cardinalres;
- Write('Value should be 7...');
- if cardinalres = 7 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- {$IFDEF FPC}
- WriteLn('------------------- CARDINAL -----------------------');
- { special tests for results }
- Writeln('special numeric values tests...');
- cardinalres := $7FFFFFFF;
- cardinalcnt := $80000000;
- cardinalres := cardinalres div cardinalcnt;
- Write('Value should be 0...');
- if cardinalres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- cardinalres := $7FFFFFFF;
- cardinalcnt := $80000000;
- cardinalres := cardinalcnt div cardinalres;
- Write('Value should be 1...');
- if cardinalres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- cardinalcnt := $80000;
- cardinalres := $12345;
- cardinalres := cardinalcnt div cardinalres;
- Write('Value should be 7...');
- if cardinalres = 7 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- cardinalres := 24;
- cardinalres := cardinalres div 4;
- Write('Value should be 6...');
- if cardinalres = 6 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- cardinalres := 24;
- cardinalres := cardinalres mod 4;
- Write('Value should be 0...');
- if cardinalres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- cardinalres := 136;
- cardinalcnt := 13;
- cardinalres := cardinalres div cardinalcnt;
- Write('Value should be 10...');
- if cardinalres = 10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- cardinalres := 10101010;
- cardinalcnt := 13;
- cardinalres := cardinalres mod cardinalcnt;
- Write('Value should be 10...');
- if cardinalres = 10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- cardinalres := 11111111;
- cardinalres := cardinalres div getcardinalcnt;
- Write('Value should be 1111111...');
- if cardinalres = 1111111 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- cardinalres := 1111111;
- cardinalres := cardinalres mod getcardinalcnt;
- Write('Value should be 1...');
- if cardinalres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- cardinalcnt := 2;
- cardinalres := getcardinalcnt div cardinalcnt;
- Write('Value should be 5...');
- if cardinalres = 5 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- cardinalcnt := 3;
- cardinalres := getcardinalcnt mod cardinalcnt;
- Write('Value should be 1...');
- if cardinalres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('--------------------- INT64 ------------------------');
- { special tests for results }
- Writeln('special numeric values tests...');
- int64res := $7FFFFFFF shl 32;
- int64cnt := $80000000 shl 32;
- int64res := int64res div int64cnt;
- Write('Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- int64res := $7FFFFFFF shl 32;
- int64cnt := $80000000 shl 32;
- int64res := int64cnt div int64res;
- Write('Value should be -1...');
- if int64res = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res := $7FFFFFFF;
- int64cnt := $80000000;
- int64res := int64res div int64cnt;
- Write('Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- Writeln('special numeric values tests...');
- int64res := $7FFFFFFF;
- int64cnt := $80000000;
- int64res := int64cnt div int64res;
- Write('Value should be -1...');
- if int64res = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- int64res := 24;
- int64res := int64res div 4;
- Write('Value should be 6...');
- if int64res = 6 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : power of 2 ordconstn }
- { LEFT : LOC_REFERENCE }
- int64res := 24;
- int64res := int64res mod 4;
- Write('Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- int64res := 136;
- int64cnt := -13;
- int64res := int64res div int64cnt;
- Write('Value should be -10...');
- if int64res = -10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REFERENCE }
- int64res := 10101010;
- int64cnt := -13;
- int64res := int64res mod int64cnt;
- Write('Value should be 10...');
- if int64res = 10 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- int64res := -11111111;
- int64res := int64res div getint64cnt;
- Write('Value should be 1111111...');
- if int64res = 1111111 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REGISTER }
- { LEFT : LOC_REFERENCE }
- int64res := -1111111;
- int64res := int64res mod getint64cnt;
- Write('Value should be -1...');
- if int64res = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- int64cnt := 2;
- int64res := getint64cnt div int64cnt;
- Write('Value should be -5...');
- if int64res = -5 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { RIGHT : LOC_REFERENCE }
- { LEFT : LOC_REGISTER }
- int64cnt := 3;
- int64res := getint64cnt mod int64cnt;
- Write('Value should be -1...');
- if int64res = -1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- {$ENDIF}
- end.
|