Update instruction builder

This commit is contained in:
Werner
2023-06-08 17:57:43 -03:00
parent c8d0a29a64
commit a82cf2bf4e

View File

@ -20,12 +20,11 @@ export default function Home() {
const { updateProgram } = useContext(ProgramContext); const { updateProgram } = useContext(ProgramContext);
const handleClick = () => { const handleClick = () => {
const program = { name: 'John', age: 25 }; updateProgram(instructionList);
updateProgram(program);
router.push('/runner'); router.push('/runner');
}; };
const [instructionList, setInstructionList] = useState([]); let [instructionList, setInstructionList] = useState([{}, {}, {}, {}, {}, {}]);
return ( return (
<> <>
@ -56,49 +55,41 @@ export default function Home() {
<Button className="ms-4" variant="primary" onClick={handleClick}>Execute</Button> <Button className="ms-4" variant="primary" onClick={handleClick}>Execute</Button>
</Col> </Col>
</Row> </Row>
<Row className="mb-3">
<Col>
<Form.Control
className="form-control-sm"
type="number"
placeholder="Select number of instructions"
/>
</Col>
</Row>
<Row className="row my-4"> <Row className="row my-4">
<Col> <Col>
<Table bordered hover> <Table bordered hover>
<thead> <thead>
<tr> <tr>
<th>Op</th> <th>OP</th>
<th>RD</th> <th>RD</th>
<th>RS</th> <th>RS</th>
<th>RT</th> <th>RT</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{instructionList.map((instr, index) => ( {instructionList.map((d, i) => (
<tr> <tr>
<td>{`${instr.instrucao.operacao} ${instr.instrucao.registradorR} ${instr.instrucao.registradorS} ${instr.instrucao.registradorT}`}</td>
<td> <td>
<option value="">Operand</option> <Form.Select aria-label="Default select example">
<option value="ADD">ADD</option> <option value="">-- Select --</option>
<option value="ADDD">ADDD</option> <option value="ADD">ADD</option>
<option value="BEQ">BEQ</option> <option value="ADDD">ADDD</option>
<option value="BNEZ">BNEZ</option> <option value="BEQ">BEQ</option>
<option value="DADDUI">DADDUI</option> <option value="BNEZ">BNEZ</option>
<option value="DIVD">DIVD</option> <option value="DADDUI">DADDUI</option>
<option value="LD">LD</option> <option value="DIVD">DIVD</option>
<option value="MULTD">MULTD</option> <option value="LD">LD</option>
<option value="SD">SD</option> <option value="MULTD">MULTD</option>
<option value="SUBD">SUBD</option> <option value="SD">SD</option>
<option value="SUBD">SUBD</option>
</Form.Select>
</td> </td>
<td> <td>
<Form.Control <Form.Control
className="form-control" className="form-control"
type="text" type="text"
name={r} name={`formNameR{i}`}
id={r} id={`formIdR{i}`}
size="3" size="3"
maxLength="3" maxLength="3"
/> />
@ -107,8 +98,8 @@ export default function Home() {
<Form.Control <Form.Control
className="form-control" className="form-control"
type="text" type="text"
name={s} name={`formNameS{i}`}
id={s} id={`formIdS{i}`}
size="3" size="3"
maxLength="5" maxLength="5"
/> />
@ -117,8 +108,8 @@ export default function Home() {
<Form.Control <Form.Control
className="form-control" className="form-control"
type="text" type="text"
name={t} name={`formNameT{i}`}
id={t} id={`formIdT{i}`}
size="3" size="3"
maxLength="3" maxLength="3"
/> />