Skip to content

Add MIPS CP1 instructions to disassembler #235

Closed
pavelkryukov opened this issue Nov 22, 2017 · 16 comments
Closed

Add MIPS CP1 instructions to disassembler #235

pavelkryukov opened this issue Nov 22, 2017 · 16 comments
Assignees
Labels
4 Features of medium complexity which usually require infrastructure enhancements. enhancement Adds a new feature to simulation. good second issue Good task to continue with MIPT-MIPS development S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA

Comments

@pavelkryukov
Copy link
Member

pavelkryukov commented Nov 22, 2017

FPU instructions are part of MIPS ISA (see part B). We want to start with instruction decoding only.

http://math-atlas.sourceforge.net/devel/assembly/mips-iv.pdf

Use our current MIPS disassembler code to introduce the floating point instructions.

@pavelkryukov pavelkryukov added 4 Features of medium complexity which usually require infrastructure enhancements. enhancement Adds a new feature to simulation. S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA labels Nov 22, 2017
@pavelkryukov pavelkryukov added this to the Enhanced MIPS milestone Nov 22, 2017
@pavelkryukov pavelkryukov changed the title Add FPU coprocessor instructions to disassembler Add CP1 coprocessor instructions to disassembler Oct 4, 2018
@pavelkryukov pavelkryukov changed the title Add CP1 coprocessor instructions to disassembler Add CP1 instructions to disassembler Oct 4, 2018
@pavelkryukov pavelkryukov added the good second issue Good task to continue with MIPT-MIPS development label Oct 4, 2018
@pavelkryukov pavelkryukov removed this from the Enhanced MIPS milestone Oct 10, 2018
@pavelkryukov pavelkryukov changed the title Add CP1 instructions to disassembler Add MIPS CP1 instructions to disassembler Mar 8, 2019
@bova-ev bova-ev self-assigned this Mar 17, 2019
@pavelkryukov
Copy link
Member Author

@DavidRabbitson
The best way to generate unit tests is to:

  1. Uncomment FPU instructions in https://github.com/MIPT-ILab/mips-traces/blob/master/tt.core.universal.s
  2. Build the file with MIPS assembler
  3. Dump its contents with MIPS objdump (mips-unknown-gnu-linux-objdump -d filename.out)

Then you can implement the code in TDD manner.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 19, 2019

Ok. Now I'm learning FPU's instructions structure. First enhancements will be on these weekends.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 22, 2019

How do I add instructions to mips_instr.cpp like add.s and add.d if they have the same function code?

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 22, 2019
@pavelkryukov
Copy link
Member Author

pavelkryukov commented Mar 22, 2019

For example, you can add different tables for different formats

@bova-ev
Copy link
Contributor

bova-ev commented Mar 22, 2019

How do I add tables to the decoder if instructions with COP1=0x11 opcode have different defining fields?

switch ( instr.opcode)
{
case 0x0: return get_table_entry( isaMapR<I>, instr.funct);
case 0x1: return get_table_entry( isaMapRI<I>, instr.rt);
case 0x10: return get_table_entry( isaMapCOP0<I>, instr.rs);
case 0x1C: return get_table_entry( isaMapMIPS32<I>, instr.funct);
default: return get_table_entry( isaMapIJ<I>, instr.opcode);
}

I mean instruction add.s is defined by the funct field and bc1f is defined by the fmt/rs field.

@pavelkryukov
Copy link
Member Author

I think it may be handled in a separate method where you can check functors etc.

 switch ( instr.opcode) 
 { 
     case 0x0:  return get_table_entry( isaMapR<I>,      instr.funct); 
     case 0x1:  return get_table_entry( isaMapRI<I>,     instr.rt); 
     case 0x10: return get_table_entry( isaMapCOP0<I>,   instr.rs);
     case 0x11: return get_cp1_entry( instr); 
     case 0x1C: return get_table_entry( isaMapMIPS32<I>, instr.funct); 
     default:   return get_table_entry( isaMapIJ<I>,     instr.opcode); 
 }

By the way, may you check-in the tests, even if they are disabled for now?

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 22, 2019
bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 24, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 25, 2019

How can I define the same instruction if in MIPS I it does not have any inputs except offset and in MIPS IV it has one more input?
image

@pavelkryukov
Copy link
Member Author

cc = 0 implied means that it is implied by compiler or assembler. We have to implement the generic case.

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 25, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 25, 2019

Instructions mfc1 and mtc1 have the same order of arguments rt, fs, but in first case rt is destination and in second is source. Can I reorder them like in mtc0 and mfc0 case or should I make them like reference says?

CHECK(MIPS32Instr(0x408d2000).get_disasm() == "mfc0 $a0, $Cause");

CHECK(MIPS32Instr(0x40046800).get_disasm() == "mtc0 $Cause, $a0");

@pavelkryukov
Copy link
Member Author

I prefer to stick to our conventions where destination always goes first, and sources follow it.

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 25, 2019
@pavelkryukov
Copy link
Member Author

pavelkryukov commented Mar 25, 2019

  • lwc1
  • swc1
  • ldc1
  • sdc1
  • lwxc1
  • swxc1
  • ldxc1
  • sdxc1
  • mtc1
  • mfc1
  • dmtc1
  • dmfc1
  • ctc1
  • cfc1
  • add
  • sub
  • mul
  • div
  • abs
  • neg
  • sqrt
  • c
  • recip
  • rsqrt
  • madd
  • msub
  • nmadd
  • nmsub
  • cvt
  • round
  • trunc
  • ceil
  • floor
  • mov
  • movt
  • movf
  • movz
  • movn
  • bc1t
  • bc1f
  • bc1tl
  • bc1tf

@bova-ev
Copy link
Contributor

bova-ev commented Mar 25, 2019

Oh, thats better.

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 26, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 26, 2019

How can I add Src3 to implement madd.fmt instructions? I don't feel that adding src3 here is good idea.

template<typename I>
struct MIPSTableEntry
{

@pavelkryukov
Copy link
Member Author

Ouch. Let's put these instructions aside for now.

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 27, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 27, 2019

Do I need to implement 3rd source print?

@pavelkryukov
Copy link
Member Author

Yes, I think that would be useful

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4 Features of medium complexity which usually require infrastructure enhancements. enhancement Adds a new feature to simulation. good second issue Good task to continue with MIPT-MIPS development S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA
Projects
None yet
Development

No branches or pull requests

2 participants