[fpc-devel] Some Opcodes missing in internal assembler for mips32r2

Michael Ring mail at michael-ring.org
Tue May 28 23:26:46 CEST 2013


I did the changes, parts of the opcodes now work fine, I think I have 
found the problem with the li + and + mfc0 op-codes, if last parameter 
is 0 then the asm statement is generated wrong:

This works:
     and    $a0,$a0,1

this does not work:
     and    $a0,$a0,0

result is:

pic32mx1xxfxxxb.s:107: Error: absolute expression required `and $a0,$a0,'

I am now having troubles with the syntax for mfc0 and mtc0:

mfc0    $t0,$12, 1 //_CP0_STATUS

gets translated to:

mfc0 $t0,$t4,1

which the assembler does not like, it needs $12 and not $t4:

pic32mx1xxfxxxb.s:37: Error: Illegal operands `mfc0 $t0,$t4,1'

Any ideas what to do here?

Michael



Index: opcode.inc
===================================================================
--- opcode.inc    (revision 24626)
+++ opcode.inc    (working copy)
@@ -206,4 +206,11 @@
  A_SHL64SUB,
  A_SHR64SUB,
  A_XOR64SUB,
+A_EHB,
+A_EXT,
+A_INS,
+A_MFC0,
+A_MTC0,
+A_SDBBP,
+A_WRPGPR,
  A_END_DEF
Index: aasmcpu.pas
===================================================================
--- aasmcpu.pas    (revision 24626)
+++ aasmcpu.pas    (working copy)
@@ -57,6 +57,7 @@
      constructor op_reg_reg_ref(op: tasmop; _op1, _op2: tregister; 
const _op3: treference);
      constructor op_reg_reg_const(op: tasmop; _op1, _op2: tregister; 
_op3: aint);
      constructor op_reg_const_reg(op: tasmop; _op1: tregister; _op2: 
aint; _op3: tregister);
+    constructor op_reg_reg_const_const(op: tasmop; _op1: tregister; 
_op2: tregister; _op3: aint; _op4: aint);

      { this is for Jmp instructions }
      constructor op_sym(op: tasmop; _op1: tasmsymbol);
@@ -196,6 +198,15 @@
    loadreg(2, _op3);
  end;

+constructor taicpu.op_reg_reg_const_const(op: tasmop; _op1: tregister; 
_op2: tregister; _op3: aint; _op4: aint);
+begin
+  inherited create(op);
+  ops := 4;
+  loadreg(0, _op1);
+  loadreg(1, _op2);
+  loadconst(2, _op3);
+  loadconst(3, _op4);
+end;

  constructor taicpu.op_sym(op: tasmop; _op1: tasmsymbol);
  begin
@@ -397,7 +408,10 @@
        A_SGTU,
        A_SLE,
        A_SLEU,
-      A_SNE];
+      A_SNE,
+      A_EXT,
+      A_INS,
+      A_MFC0];

        begin
          result := operand_read;
Index: strinst.inc
===================================================================
--- strinst.inc    (revision 24626)
+++ strinst.inc    (working copy)
@@ -206,4 +206,11 @@
  'shl64sub',
  'shr64sub',
  'xor64sub',
+'ehb',
+'ext',
+'ins',
+'mfc0',
+'mtc0',
+'sdbbp',
+'wrpgpr',
  'end_def'

Am 28.05.13 21:49, schrieb Sergei Gorelkin:
> 28.05.2013 23:40, Michael Ring пишет:
>> Thank you Sergei, I will have a look at that code.
>>
>> I have just finished inserting ugly .long 0xxxxxx statements in my 
>> code to hardcode the missing
>> pieces, I am really glad you answered ;-) ;-)
>>
>> I also found some statements that get translated wrong:
>>
>> and     $a0,$a0,0
>>
>> and     $a1,$a1,0
>>
>> li      $t2,0
>>
>> the statements are missing the last param in the generated assembler 
>> file:
>>
>> pic32mx1xxfxxxb.s:87: Error: absolute expression required `li $t2,'
>> pic32mx1xxfxxxb.s:102: Error: absolute expression required `and 
>> $a0,$a0,'
>>
>> I guess this needs to be fixed in mips/aasmcpu.pas
>>
> That's strange, at least 'li' is present in RTL MIPS-specific 
> assembler routines and it seems to be handled correctly.
>
> Regards,
> Sergei
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>




More information about the fpc-devel mailing list