Skip to content

Commit 46391d7

Browse files
committed
Update displayOperands to handle optional operands
The displayOperands function previously did not distinguish between optional and required operands. This change updates the function to display optional operands within square brackets. `vd,vs2,vs1,[,vm]`
1 parent aaf9257 commit 46391d7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/App.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ class App extends Component {
3939
};
4040
}
4141

42+
displayOperands(operands) {
43+
let all = "";
44+
let comma = "";
45+
46+
for (let i = 0; i < operands.length; i++) {
47+
if (operands[i].optional) {
48+
all += comma + "[," + operands[i].name + "]";
49+
} else {
50+
all += comma + operands[i].name;
51+
}
52+
comma = ",";
53+
}
54+
55+
return all;
56+
}
57+
58+
4259
displayMnemonic(item) {
4360
const spaces = " ";
4461

0 commit comments

Comments
 (0)