diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 87882258b4..c86f75c65b 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -1155,6 +1155,13 @@ unit cgcpu; begin optimize_op_const(size, op, a); opcode := topcg2tasmop[op]; + if (a >0) and (a<=high(dword)) then + a:=longint(dword(a)) + else if (a>=low(longint)) then + a:=longint(a) + else + internalerror(201810201); + case op of OP_NONE : begin @@ -2549,16 +2556,16 @@ unit cgcpu; begin hreg:=cg.getintregister(list,OS_INT); { cg.a_load_const_reg provides optimized loading to register for special cases } - cg.a_load_const_reg(list,OS_S32,longint(highvalue),hreg); + cg.a_load_const_reg(list,OS_S32,tcgint(highvalue),hreg); { don't use cg.a_op_const_reg() here, because a possible optimized ADDQ/SUBQ wouldn't set the eXtend bit } - list.concat(taicpu.op_const_reg(opcode,S_L,longint(lowvalue),regdst.reglo)); + list.concat(taicpu.op_const_reg(opcode,S_L,tcgint(lowvalue),regdst.reglo)); list.concat(taicpu.op_reg_reg(xopcode,S_L,hreg,regdst.reghi)); end; OP_AND,OP_OR,OP_XOR: begin - cg.a_op_const_reg(list,op,OS_S32,longint(lowvalue),regdst.reglo); - cg.a_op_const_reg(list,op,OS_S32,longint(highvalue),regdst.reghi); + cg.a_op_const_reg(list,op,OS_S32,tcgint(lowvalue),regdst.reglo); + cg.a_op_const_reg(list,op,OS_S32,tcgint(highvalue),regdst.reghi); end; { this is handled in 1st pass for 32-bit cpus (helper call) } OP_IDIV,OP_DIV, diff --git a/compiler/m68k/ra68kmot.pas b/compiler/m68k/ra68kmot.pas index 7443319852..e98fcf3fad 100644 --- a/compiler/m68k/ra68kmot.pas +++ b/compiler/m68k/ra68kmot.pas @@ -82,11 +82,11 @@ unit ra68kmot; function try_to_consume(t : tasmtoken):boolean; procedure consume_all_until(tokens : tasmtokenset); function findopcode(const s: string; var opsize: topsize): tasmop; - Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : longint; - Procedure BuildConstant(maxvalue: longint); + Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint; + Procedure BuildConstant(maxvalue: tcgint); Procedure BuildRealConstant(typ : tfloattype); Procedure BuildScaling(const oper:tm68koperand); - Function BuildRefExpression: longint; + Function BuildRefExpression: tcgint; procedure BuildReference(const oper:tm68koperand); procedure BuildRegList(const oper:tm68koperand); procedure BuildRegPair(const oper:tm68koperand); @@ -617,9 +617,9 @@ const - Function tm68kmotreader.BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : longint; + Function tm68kmotreader.BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint; {*********************************************************************} - { FUNCTION BuildExpression: longint } + { FUNCTION BuildExpression: tcgint } { Description: This routine calculates a constant expression to } { a given value. The return value is the value calculated from } { the expression. } @@ -930,7 +930,7 @@ const end; - Procedure tm68kmotreader.BuildConstant(maxvalue: longint); + Procedure tm68kmotreader.BuildConstant(maxvalue: tcgint); {*********************************************************************} { PROCEDURE BuildConstant } { Description: This routine takes care of parsing a DB,DD,or DW } @@ -944,7 +944,7 @@ const {*********************************************************************} var expr: string; - value : longint; + value : tcgint; begin Repeat Case actasmtoken of @@ -1055,9 +1055,9 @@ const end; - Function TM68kMotreader.BuildRefExpression: longint; + Function TM68kMotreader.BuildRefExpression: tcgint; {*********************************************************************} - { FUNCTION BuildRefExpression: longint } + { FUNCTION BuildRefExpression: tcgint } { Description: This routine calculates a constant expression to } { a given value. The return value is the value calculated from } { the expression. } @@ -1173,7 +1173,7 @@ const {*********************************************************************} procedure TM68kMotreader.BuildReference(const oper:tm68koperand); var - l:longint; + l:tcgint; code: integer; str: string; begin @@ -1419,7 +1419,8 @@ const Message(asmr_e_invalid_operand_type); { identifiers are handled by BuildExpression } oper.opr.typ := OPR_CONSTANT; - oper.opr.val :=BuildExpression(true,@tempstr); + l:=BuildExpression(true,@tempstr); + oper.opr.val :=aint(l); if tempstr<>'' then begin l:=oper.opr.val; @@ -1708,7 +1709,7 @@ const AS_DD: begin Consume(AS_DD); - BuildConstant(longint($ffffffff)); + BuildConstant(tcgint($ffffffff)); end; AS_XDEF: begin