Java Reference
In-Depth Information
The method execute() derives from the straightforward application of the
procedure presented in Sidebar 5.2 to the FSA shown in Figure 5.8.
public void execute() {
switch (state){
case FETCH_entry:
bus.command # RAM.RAM_READ;
bus.address # PC;
state !! ;
case FETCH:
if (bus.command.equals(RAM.ACK))
state # DECODE_entry;
break ;
case DECODE_entry:
IR # bus.data;
PC !! ;
state !! ;
case DECODE:
if (code(IR).equals(HALT))
state # EXEC_HALT_entry;
if (code(IR).equals(JUMP))
state # EXEC_JUMP_entry;
if (code(IR).equals(JUMPZ))
state # EXEC_JUMPZ_entry;
if (code(IR).equals(LOADA))
state # EXEC_LOADA_entry;
if (code(IR).equals(LOADB))
state # EXEC_LOADB_entry;
if (code(IR).equals(STOREA))
state # EXEC_STOREA_entry;
if (code(IR).equals(STOREB))
state # EXEC_STOREB_entry;
if (code(IR).equals(MOVEAB))
state # EXEC_MOVEAB_entry;
if (code(IR).equals(ADD))
state # EXEC_ADD_entry;
break ;
case EXEC_HALT_entry:
state !! ;
case EXEC_HALT:
break ;
case EXEC_JUMP_entry:
PC # arg(IR);
state !! ;
case EXEC_JUMP:
state # FETCH_entry;
break ;
Search WWH ::




Custom Search