mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 04:02:25 +00:00
fixed Longint to Byte Arr function; -- noch
This commit is contained in:
parent
247852e0b7
commit
c549f5847b
3 changed files with 682 additions and 689 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@ TYPE pchar = POINTER TO ARRAY 1 OF CHAR;
|
||||||
i := 0;
|
i := 0;
|
||||||
REPEAT
|
REPEAT
|
||||||
SYSTEM.GET(adr + i, b);
|
SYSTEM.GET(adr + i, b);
|
||||||
lar[i] := b;
|
bar[i] := b;
|
||||||
INC(i)
|
INC(i)
|
||||||
UNTIL i = SIZE(LONGINT)
|
UNTIL i = SIZE(LONGINT)
|
||||||
END LongToByteArr;
|
END LongToByteArr;
|
||||||
|
|
@ -138,4 +138,5 @@ TYPE pchar = POINTER TO ARRAY 1 OF CHAR;
|
||||||
BEGIN
|
BEGIN
|
||||||
SYSTEM.MOVE(from, to, n);
|
SYSTEM.MOVE(from, to, n);
|
||||||
END WMOVE;
|
END WMOVE;
|
||||||
|
|
||||||
END ulmSYSTEM.
|
END ulmSYSTEM.
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
*)
|
*)
|
||||||
|
|
||||||
MODULE ulmTypes;
|
MODULE Types;
|
||||||
|
|
||||||
(* compiler-dependent type definitions;
|
(* compiler-dependent type definitions;
|
||||||
this version works for Ulm's Oberon Compilers on
|
this version works for Ulm's Oberon Compilers on
|
||||||
|
|
@ -51,24 +51,23 @@ MODULE ulmTypes;
|
||||||
|
|
||||||
TYPE
|
TYPE
|
||||||
Address* = SYS.ADDRESS;
|
Address* = SYS.ADDRESS;
|
||||||
|
UntracedAddress* = POINTER[1] TO UntracedAddressDesc;
|
||||||
|
UntracedAddressDesc* = RECORD[1] END;
|
||||||
|
|
||||||
UntracedAddress* = POINTER[1] TO UntracedAddressDesc; (*SYS.UNTRACEDADDRESS;*)
|
Count* = SYS.INT32;
|
||||||
UntracedAddressDesc* = RECORD[1] END;
|
Size* = Count;
|
||||||
|
Byte* = SYS.BYTE;
|
||||||
Count* = SYS.INT32;
|
IntAddress* = SYS.INT32;
|
||||||
Size* = Count;
|
Int8* = SYS.INT8;
|
||||||
Byte* = SYS.BYTE;
|
Int16* = SYS.INT16;
|
||||||
IntAddress* = LONGINT;
|
Int32* = SYS.INT32;
|
||||||
Int8* = SYS.INT8;
|
Real32* = LONGREAL;
|
||||||
Int16* = SYS.INT16;
|
Real64* = LONGREAL;
|
||||||
Int32* = SYS.INT32;
|
|
||||||
Real32* = REAL;
|
|
||||||
Real64* = LONGREAL;
|
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
bigEndian* = 0; (* SPARC, M68K etc *)
|
bigEndian* = 0; (* SPARC, M68K etc *)
|
||||||
littleEndian* = 1; (* Intel 80x86, VAX etc *)
|
littleEndian* = 1; (* Intel 80x86, VAX etc *)
|
||||||
byteorder* = littleEndian; (* machine-dependent constant *)
|
byteorder* = littleEndian; (* machine-dependent constant *)
|
||||||
TYPE
|
TYPE
|
||||||
ByteOrder* = SHORTINT; (* bigEndian or littleEndian *)
|
ByteOrder* = SHORTINT; (* bigEndian or littleEndian *)
|
||||||
|
|
||||||
|
|
@ -77,14 +76,27 @@ MODULE ulmTypes;
|
||||||
to allow for bit operations on INTEGER values
|
to allow for bit operations on INTEGER values
|
||||||
*)
|
*)
|
||||||
TYPE
|
TYPE
|
||||||
SetInt* = LONGINT; (* INTEGER type that corresponds to SET *)
|
SetInt* = INTEGER; (* INTEGER type that corresponds to SET *)
|
||||||
VAR msb* : SET;
|
CONST
|
||||||
msbIsMax*, msbIs0*: SHORTINT;
|
msb* = SYS.VAL(SET, MIN(SetInt));
|
||||||
msbindex*, lsbindex*, nofbits*: LONGINT;
|
(* most significant bit, converted to a SET *)
|
||||||
|
(* we expect msbIsMax XOR msbIs0 to be 1;
|
||||||
|
this is checked for by an assertion
|
||||||
|
*)
|
||||||
|
msbIsMax* = SYS.VAL(SHORTINT, (msb = {MAX(SET)}));
|
||||||
|
(* is 1, if msb equals {MAX(SET)} *)
|
||||||
|
msbIs0* = SYS.VAL(SHORTINT, (msb = {0}));
|
||||||
|
(* is 0, if msb equals {0} *)
|
||||||
|
msbindex* = msbIsMax * MAX(SET);
|
||||||
|
(* set element that corresponds to the most-significant-bit *)
|
||||||
|
lsbindex* = MAX(SET) - msbindex;
|
||||||
|
(* set element that corresponds to the lowest-significant-bit *)
|
||||||
|
nofbits* = MAX(SET) + 1;
|
||||||
|
(* number of elements in SETs *)
|
||||||
|
|
||||||
PROCEDURE ToInt8*(int: LONGINT) : Int8;
|
PROCEDURE ToInt8*(int: LONGINT) : Int8;
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN SYS.VAL(SHORTINT, int)
|
RETURN SHORT(SHORT(int))
|
||||||
END ToInt8;
|
END ToInt8;
|
||||||
|
|
||||||
PROCEDURE ToInt16*(int: LONGINT) : Int16;
|
PROCEDURE ToInt16*(int: LONGINT) : Int16;
|
||||||
|
|
@ -94,7 +106,7 @@ MODULE ulmTypes;
|
||||||
|
|
||||||
PROCEDURE ToInt32*(int: LONGINT) : Int32;
|
PROCEDURE ToInt32*(int: LONGINT) : Int32;
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN SYS.VAL(INTEGER, int)
|
RETURN int
|
||||||
END ToInt32;
|
END ToInt32;
|
||||||
|
|
||||||
PROCEDURE ToReal32*(real: LONGREAL) : Real32;
|
PROCEDURE ToReal32*(real: LONGREAL) : Real32;
|
||||||
|
|
@ -104,25 +116,9 @@ MODULE ulmTypes;
|
||||||
|
|
||||||
PROCEDURE ToReal64*(real: LONGREAL) : Real64;
|
PROCEDURE ToReal64*(real: LONGREAL) : Real64;
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN real
|
RETURN SHORT(real)
|
||||||
END ToReal64;
|
END ToReal64;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
msb := SYS.VAL(SET, MIN(SetInt));
|
|
||||||
(* most significant bit, converted to a SET *)
|
|
||||||
(* we expect msbIsMax XOR msbIs0 to be 1;
|
|
||||||
this is checked for by an assertion
|
|
||||||
*)
|
|
||||||
msbIsMax := SYS.VAL(SHORTINT, (msb = {MAX(SET)}));
|
|
||||||
(* is 1, if msb equals {MAX(SET)} *)
|
|
||||||
msbIs0 := SYS.VAL(SHORTINT, (msb = {0}));
|
|
||||||
(* is 0, if msb equals {0} *)
|
|
||||||
msbindex := msbIsMax * MAX(SET);
|
|
||||||
(* set element that corresponds to the most-significant-bit *)
|
|
||||||
lsbindex := MAX(SET) - msbindex;
|
|
||||||
(* set element that corresponds to the lowest-significant-bit *)
|
|
||||||
nofbits := MAX(SET) + 1;
|
|
||||||
(* number of elements in SETs *)
|
|
||||||
|
|
||||||
ASSERT((msbIs0 = 1) & (msbIsMax = 0) OR (msbIs0 = 0) & (msbIsMax = 1));
|
ASSERT((msbIs0 = 1) & (msbIsMax = 0) OR (msbIs0 = 0) & (msbIsMax = 1));
|
||||||
END ulmTypes.
|
END Types.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue