123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- {***********************************************************}
- { CODE GENERATOR TEST SUITE *}
- {***********************************************************}
- { NODE TESTED : secondshlshr() *}
- {***********************************************************}
- { PRE-REQUISITES: secondload() }
- { secondassign() }
- { secondtypeconv() }
- { secondinline() with strings only! }
- { secondadd() comparison }
- { secondifn() }
- {***********************************************************}
- { DEFINES : FPC if target is Free Pascal compiler }
- {***********************************************************}
- { REMARKS: None }
- {***********************************************************}
- Program tshlshr;
- {----------------------------------------------------}
- { Cases to test: }
- { RIGHT NODE (shift count value) }
- { - LOC_CREGISTER }
- { - LOC_REFERENCE / LOC_MEM }
- { - LOC_REGISTER }
- { - numeric constant }
- { LEFT NODE (value to shift) }
- { - LOC_CREGISTER }
- { - LOC_REFERENCE / LOC_MEM }
- { - LOC_REGISTER }
- {----------------------------------------------------}
- var
- longres : longint;
- longcnt : longint;
- bytecnt : shortint;
- byteres : shortint;
- {$IFDEF FPC}
- int64res : int64;
- int64cnt : int64;
- {$ENDIF}
- Begin
- WriteLn('------------------------------ LONGINT --------------------------------');
- { left : LOC_REFERENCE }
- { right : numeric constant }
- WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
- longres:=1;
- longres := longres shl 15;
- Write('(SHL) Value should be 32768...');
- if longres = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- longres := longres shl 15;
- Write('(SHL) Value should be -32768...');
- if longres = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=1;
- longres := longres shl 33;
- Write('(SHL) Value should be 2...');
- if longres = 2 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=$8000;
- longres := longres shr 15;
- Write('(SHR) Value should be 1...');
- if longres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- longres := longres shr 15;
- Write('(SHR) Value should be 131071...');
- if longres = 131071 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=$FFFF;
- longres := longres shr 33;
- Write('(SHR) Value should be 32767...');
- if longres = 32767 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { left : LOC_REFERENCE }
- { right : LOC_REFERENCE }
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
- longres := 1;
- longcnt := -2;
- longres:=longres shl longcnt ;
- Write('(SHL) Value should be 1073741824...');
- if longres = 1073741824 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=1;
- longcnt:=15;
- longres := longres shl longcnt;
- Write('(SHL) Value should be 32768...');
- if longres = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- longcnt := 15;
- longres := longres shl longcnt;
- Write('(SHL) Value should be -32768...');
- if longres = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres := 1;
- longcnt := -2;
- longres:=longres shr longcnt ;
- Write('(SHR) Value should be 0...');
- if longres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=32768;
- longcnt:=15;
- longres := longres shr longcnt;
- Write('(SHR) Value should be 1...');
- if longres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- longcnt := 15;
- longres := longres shl longcnt;
- Write('(SHR) Value should be -32768...');
- if longres = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { left : LOC_REFERENCE }
- { right : LOC_REGISRER }
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
- longres := 1;
- bytecnt := -2;
- longres:=longres shl bytecnt ;
- Write('(SHL) Value should be 1073741824...');
- if longres = 1073741824 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=1;
- bytecnt:=15;
- longres := longres shl bytecnt;
- Write('(SHL) Value should be 32768...');
- if longres = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- bytecnt := 15;
- longres := longres shl bytecnt;
- Write('(SHL) Value should be -32768...');
- if longres = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres := 1;
- bytecnt := -2;
- longres:=longres shr bytecnt ;
- Write('(SHR) Value should be 0...');
- if longres = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=32768;
- bytecnt:=15;
- longres := longres shr bytecnt;
- Write('(SHR) Value should be 1...');
- if longres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- longres:=-1;
- bytecnt := 15;
- longres := longres shr bytecnt;
- Write('(SHR) Value should be 131071...');
- if longres = 131071 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- WriteLn('(left) : LOC_REGISTER; (right) : LOC_REGISTER');
- byteres := 1;
- bytecnt := 2;
- byteres := byteres shl bytecnt;
- Write('(SHL) Value should be 4...');
- if longres = 4 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- byteres := 4;
- bytecnt := 2;
- byteres := byteres shr bytecnt;
- Write('(SHR) Value should be 1...');
- if longres = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- {$IFDEF FPC}
- WriteLn('------------------------------ INT64 --------------------------------');
- { left : LOC_REFERENCE }
- { right : numeric constant }
- WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
- int64res:=1;
- int64res := int64res shl 15;
- Write('(SHL) Value should be 32768...');
- if int64res = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=-1;
- int64res := int64res shl 15;
- Write('(SHL) Value should be -32768...');
- if int64res = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=1;
- int64res := int64res shl 65;
- Write('(SHL) Value should be 2...');
- if int64res = 2 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=$8000;
- int64res := int64res shr 15;
- Write('(SHR) Value should be 1...');
- if int64res = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { int64res:=-1;
- int64res := int64res shr 15;
- Write('(SHR) Value should be 131071...');}
- int64res:=$FFFF;
- int64res := int64res shr 65;
- Write('(SHR) Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { left : LOC_REFERENCE }
- { right : LOC_REFERENCE }
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
- int64res := 1;
- int64cnt := -2;
- int64res:=int64res shl int64cnt ;
- Write('(SHL) Value should be 1073741824...');
- if int64res = 1073741824 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=1;
- int64cnt:=15;
- int64res := int64res shl int64cnt;
- Write('(SHL) Value should be 32768...');
- if int64res = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=-1;
- int64cnt := 15;
- int64res := int64res shl int64cnt;
- Write('(SHL) Value should be -32768...');
- if int64res = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res := 1;
- int64cnt := -2;
- int64res:=int64res shr int64cnt ;
- Write('(SHR) Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=32768;
- int64cnt:=15;
- int64res := int64res shr int64cnt;
- Write('(SHR) Value should be 1...');
- if int64res = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=-1;
- int64cnt := 15;
- int64res := int64res shl int64cnt;
- Write('(SHR) Value should be -32768...');
- if int64res = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { left : LOC_REFERENCE }
- { right : LOC_REGISRER }
- WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
- int64res := 1;
- bytecnt := -2;
- int64res:=int64res shl bytecnt ;
- Write('(SHL) Value should be 1073741824...');
- if int64res = 1073741824 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=1;
- bytecnt:=15;
- int64res := int64res shl bytecnt;
- Write('(SHL) Value should be 32768...');
- if int64res = 32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=-1;
- bytecnt := 15;
- int64res := int64res shl bytecnt;
- Write('(SHL) Value should be -32768...');
- if int64res = -32768 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res := 1;
- bytecnt := -2;
- int64res:=int64res shr bytecnt ;
- Write('(SHR) Value should be 0...');
- if int64res = 0 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- int64res:=32768;
- bytecnt:=15;
- int64res := int64res shr bytecnt;
- Write('(SHR) Value should be 1...');
- if int64res = 1 then
- WriteLn('Success.')
- else
- WriteLn('Failure.');
- { int64res:=-1;
- bytecnt := 15;
- int64res := int64res shr bytecnt;
- WriteLn('(SHR) Value should be 131071...',int64res);}
- {$ENDIF}
- end.
|