# Computer Architecture Lab/SS2014/group 4 lab 2

Proposals for ISAs

## Proposal 1[edit | edit source]

A MIPS processor extended such that r1,r2 behave as windows into the top 2 elements of a return stack and r3,r4 behave as windows into a data stack. This should eliminate the performance decrease from function calls. The instruction set does not need to, but could, be changed from the standard MIPS32 ISA as common stack operations can already interpreted from the current instruction set.

For example ( using forth notation stack( before -- after ) )

- dup ( a -- a a ): add $4 $4 $0
- drop ( a -- ): add $0 $4 $0
- swap ( a b -- b a ): add $4 $3 $0
- over ( a b -- a b a ): add $5 $3 $0; add $4 $5 $0

## Proposal 2[edit | edit source]

A stack machine with a data stack, return stack, variable stack, floating point stack and 28 temporary registers. Functional units are wired to the data stack.

Most instructions are 5-bit wide and are packed inside 32-bit words. Instructions that load an immediate value or jump are a full word wide and use 27 bits for the value. Instructions that can operate on a different stack than the data stack are 5-bit wide and use the following 5-bit to determine the point of operation.

mnemonic | Effect | Details |
---|---|---|

nop | -- | -- |

over[s] | s( a b -- a b a ) | Performs over operation on stack specified by s |

dup[s] | s( a -- a a ) | Performs over operation on stack specified by s |

swap[s] | s( a b -- b a ) | Performs swap operation on stack specified by s |

lim | D( -- x ) | Loads an immediate x |

>[sr] | D( x -- ) | Pops an item from data stack and pushes it to another stack or scratch register |

[sr]> | D( -- [sr] ) | Pops an item from a stack or scratch register and places it on the data stack |

@[sr] | D( -- MEM[ sr ] ) | Pushes MEM[ sr ] to the data stack |

@[sr]+ | D( -- MEM[ sr++ ] ) | Pushes MEM[ sr++ ] to the data stack |

![sr] | D( x -- ) | Pops top of data stack to MEM[ sr ] |

![sr]+ | D( x -- ) | Pops top of data stack to MEM[ sr++ ] |

add | D( x y -- x+y ) | adds two top members of data stack |

sub | D( x y -- x - y ) | subtracts two top members of data stack |

mul | D( x y -- x * y ) | multiplies the two top members of the data stack |

div | D( x y -- x%y x/y ) | divides the two top members of the data stack placing x mod y and x/y on the stack |

sll | D( x y -- x<<y ) | Shifts the top of stack to the left |

slr | D( x y -- x>>y ) | Shifts the top of stack to the right |

and | D( x y -- x AND y ) | Bitwise and |

or | D( x y -- x OR y ) | Bitwise or |

not | D( x -- ~x ) | negation |

xor | D( x y -- x XOR y ) | bitwise xor |

jmp | D( -- ) | Unconditional jump |

bez | D( x -- ) | Pops stack and branches on 0 |

brp | D( x -- ) | Pops stack and branches on positive value |

call | R( -- x ) | Subroutine call, pushes return address on return stack |

ret | R( x -- ) | Pop return stack and return from subroutine |