Skip to content

Commit a3b2b80

Browse files
otonomeeclaude
andcommitted
docs: update README with pseudo-instruction support
Add comprehensive documentation for pseudo-instruction support including: - Updated Features section highlighting automatic expansion - Complete list of supported real MIPS instructions (R/I/J-type) - Detailed pseudo-instruction expansion table - Example outputs for both pseudo-instructions and regular instructions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 73438cc commit a3b2b80

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,71 @@ I made this as a fun project for my [Computer Organisation](https://www.comp.nus
1212

1313
- Decode binary/hex machine code into MIPS instructions
1414
- Encode MIPS instructions into hex machine code
15+
- Automatic pseudo-instruction expansion with detailed explanations
16+
- Support for 6 common MIPS pseudo-instructions (ble, blt, bge, bgt, move, li)
17+
18+
## Supported Instructions
19+
20+
### Real MIPS Instructions
21+
22+
**R-Type Instructions:**
23+
- add, addu, and, jr, nor, or, slt, sltu, sll, srl, sub, subu
24+
25+
**I-Type Instructions:**
26+
- addi, addiu, andi, beq, bne, lbu, lhu, ll, lui, lw, ori, slti, sltiu, sb, sc, sh, sw
27+
28+
**J-Type Instructions:**
29+
- j, jal
30+
31+
### Pseudo-Instructions
32+
33+
The converter automatically expands pseudo-instructions into their equivalent real MIPS instructions:
34+
35+
| Pseudo-Instruction | Expands To | Description |
36+
|-------------------|------------|-------------|
37+
| `ble $rs, $rt, label` | `slt $at, $rt, $rs`<br>`beq $at, $0, label` | Branch if Less Than or Equal |
38+
| `blt $rs, $rt, label` | `slt $at, $rs, $rt`<br>`bne $at, $0, label` | Branch if Less Than |
39+
| `bge $rs, $rt, label` | `slt $at, $rs, $rt`<br>`beq $at, $0, label` | Branch if Greater Than or Equal |
40+
| `bgt $rs, $rt, label` | `slt $at, $rt, $rs`<br>`bne $at, $0, label` | Branch if Greater Than |
41+
| `move $rd, $rs` | `add $rd, $rs, $0` | Copy register value |
42+
| `li $rt, imm` | `ori $rt, $0, imm`<br>or<br>`lui $rt, upper`<br>`ori $rt, $rt, lower` | Load Immediate (1 or 2 instructions based on value) |
43+
44+
## Example Output
45+
46+
### Pseudo-Instruction Expansion
47+
48+
```
49+
Input: ble $2, $3, target
50+
51+
Output:
52+
Pseudo-instruction detected: ble
53+
Expanding 'ble $2, $3, target' into:
54+
55+
1) slt $at, $3, $2
56+
# Set $at = 1 if $3 < $2, else 0
57+
2) beq $at, $0, target
58+
# Branch if $at == 0 (i.e., $2 <= $3)
59+
60+
BINARY EQUIVALENT:
61+
slt $at, $3, $2: 00000000011000100000100000101010
62+
beq $at, $0, target: 00010000001000000000000000000000
63+
64+
HEX EQUIVALENT:
65+
slt $at, $3, $2: 0062082A
66+
beq $at, $0, target: 10200000
67+
Note: Label 'target' uses placeholder offset 0
68+
```
69+
70+
### Regular Instruction Conversion
71+
72+
```
73+
Input: add $t0, $t1, $t2
74+
75+
Output:
76+
MIPS: add $t0, $t1, $t2
77+
BINARY: 00000001001010100100000000100000
78+
HEX: 012A4020
79+
```
1580

1681
## Reference Data
1782

0 commit comments

Comments
 (0)