2
0
Эх сурвалжийг харах

prepared assembler for 64bit operands

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7513 8c9fc860-2736-0410-a75d-ab315db34111
felixf 7 жил өмнө
parent
commit
c93b5b3bb2

+ 2 - 2
source/FoxARMAssembler.Mod

@@ -149,7 +149,7 @@ TYPE
 			result: BOOLEAN;
 			result: BOOLEAN;
 		BEGIN
 		BEGIN
 			IF Expression(assemblerResult, FALSE) & ((assemblerResult.type = FoxAssembler.ConstantInteger) OR (assemblerResult.type = FoxAssembler.Offset)) THEN
 			IF Expression(assemblerResult, FALSE) & ((assemblerResult.type = FoxAssembler.ConstantInteger) OR (assemblerResult.type = FoxAssembler.Offset)) THEN
-				value := assemblerResult.value;
+				value := LONGINT(assemblerResult.value);
 				result := TRUE
 				result := TRUE
 			ELSE
 			ELSE
 				value := 0;
 				value := 0;
@@ -339,7 +339,7 @@ TYPE
 						InstructionSet.InitImmediate(operand, value)
 						InstructionSet.InitImmediate(operand, value)
 
 
 					ELSIF GetNonConstant(errorPosition,symbol.identifierString, result) THEN
 					ELSIF GetNonConstant(errorPosition,symbol.identifierString, result) THEN
-						InstructionSet.InitImmediate(operand,result.value);
+						InstructionSet.InitImmediate(operand,LONGINT(result.value));
 						IF result.fixup # NIL THEN
 						IF result.fixup # NIL THEN
 							InstructionSet.AddFixup(operand,result.fixup);
 							InstructionSet.AddFixup(operand,result.fixup);
 						END;
 						END;

+ 6 - 8
source/FoxAssembler.Mod

@@ -118,7 +118,7 @@ TYPE
 	Result*= RECORD
 	Result*= RECORD
 		type*: INTEGER; (* ConstantInteger, ConstantFloat, Fixup, Offset *)
 		type*: INTEGER; (* ConstantInteger, ConstantFloat, Fixup, Offset *)
 		sizeInBits*: INTEGER;
 		sizeInBits*: INTEGER;
-		value*: LONGINT; (*! implementation restriction: operations between hugeints do not yet work *)
+		value*: HUGEINT; 
 		valueR*: LONGREAL;
 		valueR*: LONGREAL;
 		fixup*: BinaryCode.Fixup;
 		fixup*: BinaryCode.Fixup;
 	END;
 	END;
@@ -347,7 +347,7 @@ TYPE
 				result.valueR := result.value;
 				result.valueR := result.value;
 				result.type := ConstantInteger;
 				result.type := ConstantInteger;
 			ELSIF constant.type.resolved IS SyntaxTree.IntegerType THEN
 			ELSIF constant.type.resolved IS SyntaxTree.IntegerType THEN
-				result.value := constant.value.resolved(SyntaxTree.IntegerValue).value;
+				result.value := constant.value.resolved(SyntaxTree.IntegerValue).hvalue;
 				result.valueR := result.value;
 				result.valueR := result.value;
 				result.type := ConstantInteger;
 				result.type := ConstantInteger;
 			ELSIF constant.type.resolved IS SyntaxTree.FloatType THEN
 			ELSIF constant.type.resolved IS SyntaxTree.FloatType THEN
@@ -492,10 +492,8 @@ TYPE
 				IF symbol.numberType = Scanner.Integer THEN
 				IF symbol.numberType = Scanner.Integer THEN
 					x.value := symbol.integer
 					x.value := symbol.integer
 				ELSIF symbol.numberType = Scanner.Hugeint THEN
 				ELSIF symbol.numberType = Scanner.Hugeint THEN
-					(* note that 64 bit integer constants are not (yet) supported in expressions by the assembler.
-					however, the scanner interprets large 32 bit integers as hugeints (because integers are always assumed to be signed). *)
-					x.value := SYSTEM.VAL(LONGINT, symbol.hugeint); (* TODO: how to do that? *)
-					ASSERT(x.value < 0); (* the resulting 32 bit integer must be negative when interpreted as a signed value *)
+					x.value := symbol.hugeint;
+					(* ASSERT(x.value < 0); (* the resulting 32 bit integer must be negative when interpreted as a signed value *)*)
 				END;
 				END;
 				x.type := ConstantInteger;
 				x.type := ConstantInteger;
 				RETURN TRUE;
 				RETURN TRUE;
@@ -709,7 +707,7 @@ TYPE
 		END Reserve;
 		END Reserve;
 
 
 		(** if the assembler is at the last pass: put bits into the binary code section, otherwise only increment the PC **)
 		(** if the assembler is at the last pass: put bits into the binary code section, otherwise only increment the PC **)
-		PROCEDURE PutBitsIfLastPass(data: LONGINT; size: BinaryCode.Bits);
+		PROCEDURE PutBitsIfLastPass(data: HUGEINT; size: BinaryCode.Bits);
 		VAR
 		VAR
 			oldPC: LONGINT;
 			oldPC: LONGINT;
 		BEGIN
 		BEGIN
@@ -828,7 +826,7 @@ TYPE
 							ELSIF Reserve(identifier) THEN
 							ELSIF Reserve(identifier) THEN
 							ELSIF identifier = "fixed" THEN
 							ELSIF identifier = "fixed" THEN
 								IF ExpectConstantInteger(result,TRUE) THEN
 								IF ExpectConstantInteger(result,TRUE) THEN
-									code.SetAlignment(TRUE,result.value)
+									code.SetAlignment(TRUE,LONGINT(result.value))
 								END;
 								END;
 							ELSIF ~error THEN
 							ELSIF ~error THEN
 								errorPosition := pos;
 								errorPosition := pos;

+ 2 - 2
source/FoxBinaryCode.Mod

@@ -289,7 +289,7 @@ TYPE
 			INC(pc,len DIV os.unit);
 			INC(pc,len DIV os.unit);
 		END CopyBits;
 		END CopyBits;
 
 
-		PROCEDURE PutBits*(d: LONGINT; size: Bits);
+		PROCEDURE PutBits*(d: HUGEINT; size: Bits);
 		BEGIN
 		BEGIN
 			(*ASSERT(size MOD unit = 0);*)
 			(*ASSERT(size MOD unit = 0);*)
 			CheckSize(size);
 			CheckSize(size);
@@ -297,7 +297,7 @@ TYPE
 			INC(pc,size DIV os.unit);
 			INC(pc,size DIV os.unit);
 		END PutBits;
 		END PutBits;
 
 
-		PROCEDURE PutBitsAt*(at: Unit; d: LONGINT; size: Bits);
+		PROCEDURE PutBitsAt*(at: Unit; d: HUGEINT; size: Bits);
 		VAR oldpc: LONGINT;
 		VAR oldpc: LONGINT;
 		BEGIN
 		BEGIN
 			oldpc := pc;
 			oldpc := pc;

+ 2 - 2
source/FoxTRMAssembler.Mod

@@ -56,11 +56,11 @@ TYPE
 						END;
 						END;
 					END;
 					END;
 					IF memory & ExpectToken(Scanner.RightBracket) THEN
 					IF memory & ExpectToken(Scanner.RightBracket) THEN
-						instructionSet.InitMemory(operand,register1,result.value);
+						instructionSet.InitMemory(operand,register1,LONGINT(result.value));
 					ELSIF register1 # -1 THEN
 					ELSIF register1 # -1 THEN
 						instructionSet.InitRegister(operand,register1);
 						instructionSet.InitRegister(operand,register1);
 					ELSE
 					ELSE
-						instructionSet.InitImmediate(operand,result.sizeInBits,result.value);
+						instructionSet.InitImmediate(operand,result.sizeInBits,LONGINT(result.value));
 					END;
 					END;
 					IF result.fixup # NIL THEN
 					IF result.fixup # NIL THEN
 						instructionSet.AddFixup(operand,result.fixup);
 						instructionSet.AddFixup(operand,result.fixup);