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 21, 2024
1 parent aaf9257 commit 46391d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ class App extends Component {
};
}

displayOperands(operands) {
let all = "";
let comma = "";

for (let i = 0; i < operands.length; i++) {
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 46391d7

Please sign in to comment.