Skip to content

Commit

Permalink
Update displayOperands to handle optional operands
Browse files Browse the repository at this point in the history
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]`
  • Loading branch information
Linda-Njau committed Aug 19, 2024
1 parent 7c27a8c commit 7d1cb9b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ class App extends Component {
displayOperands(operands) {
let all = "";
let comma = "";

for (let i = 0; i < operands.length; i++) {
all += comma + operands[i].name;
if (operands[i].optional) {
all += comma + "[," + operands[i].name + "]";
} else {
all += comma + operands[i].name;
}
comma = ",";
}

return all;
}


displayMnemonic(item) {
const spaces = " ";
Expand Down

0 comments on commit 7d1cb9b

Please sign in to comment.