URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
[/] [eco32/] [trunk/] [doc/] [manual/] [isa/] [jump.tex] - Rev 132
Go to most recent revision | Compare with Previous | Blame | View Log
\section{Control Flow Instructions} Control flow instruction load immediate values or register values into the \pc and/or load the value of the \pc into a general-purpose register. The \eco supports unconditional {\it jumps}, conditional {\it branches}, indirect jumps, subroutine calls, subroutine returns, and indirect subroutine calls out of the box. More complex control flow schemes can be implemented by combining these instructions. A control transfer is \definition{conditional} if it only occurs on a certain condition that is computed from general-purpose registers. A control transfer is \definition{unconditional} if it always occurs. A control transfer is \definition{direct} if the target address is supplied as an immediate value. It is \definition{indirect} if the target address is supplied as a register value. A control transfer is \definition{absolute} if the value of the \pc is overwritten with a totally new value. It is \definition{relative} if the value of the \pc is modified by adding or subtracting an offset. Both relative control transfers and instructions that read the current \pc value operate on the value of the \pc {\it after} increasing it by 4 during instruction fetching. \newcommand{\branchdesc}[4]{ \subsection{#1} The #1 instruction performs a conditional direct jump to a relative immediate sign-extended 16-bit offset counted as words. The condition is evaluated by comparing two 32-bit register operands and is asserted if the first operand is #3 the second operand. \brformat{#2} \begin{effectize} \effect if $R_x #4 R_y$ then $PC \leftarrow PC + 4 * signext_{32}(offset)$ \end{effectize} } \branchdesc{BEQ}{100000}{equal to}{=} \branchdesc{BNE}{100001}{not equal to}{\neq} \branchdesc{BLE}{100010}{less or equal to (by signed comparison)}{\leq_{signed}} \branchdesc{BLEU}{100011}{less or equal to (by unsigned comparison)}{\leq_{unsigned}} \branchdesc{BLT}{100100}{less than (by signed comparison)}{<_{signed}} \branchdesc{BLTU}{100101}{less than (by unsigned comparison)}{<_{unsigned}} \branchdesc{BGE}{100110}{greater or equal to (by signed comparison)}{\geq_{signed}} \branchdesc{BGEU}{100111}{greater or equal to (by unsigned comparison)}{\geq_{unsigned}} \branchdesc{BGT}{101000}{greater than (by signed comparison)}{>_{signed}} \branchdesc{BGTU}{101001}{greater than (by unsigned comparison)}{>_{unsigned}} \subsection{J} The J instruction performs an unconditional direct jump to a relative immediate sign-extended 26-bit offset counted as words. \jformat{101010} \begin{effectize} \effect $PC \leftarrow PC + 4 * signext_{32}(offset)$ \end{effectize} \subsection{JR} The JR instruction performs an unconditional indirect jump to an absolute offset stored in a general-purpose register. It can be used for simple indirect jumps as well as to return from a subroutine. \jrformat{101011} \begin{effectize} \effect $PC \leftarrow R_{dest}$ \end{effectize} \subsection{JAL} The JAL instruction stores the current \pc value in register \#31, then performs an unconditional direct jump to a relative immediate sign-extended 26-bit offset counted as words. It is primarily used for subroutine calls. \jformat{101100} \begin{effectize} \effect $R_{31} \leftarrow PC$ \effect $PC \leftarrow PC + 4 * signext_{32}(offset)$ \end{effectize} \subsection{JALR} The JALR instruction remembers the current \pc value, then performs an unconditional indirect jump to an absolute offset stored in a general-purpose register. The previous PC value is then stored in register \#31. It is primarily used for indirect subroutine calls, such as virtual method invocations in object-oriented programming. \jrformat{101101} \begin{effectize} \effect $returnAddress \leftarrow PC$ \effect $PC \leftarrow R_{dest}$ \effect $R_{31} \leftarrow returnAddress$ \end{effectize}
Go to most recent revision | Compare with Previous | Blame | View Log