# J-type

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-916c673299a6a4b68449a577eb1349453d23093f%2Fj-type.png?alt=media" alt=""><figcaption></figcaption></figure>

## JALR (I-Format)

{% hint style="warning" %}
I'm sorry for putting JALR here. Actually JALR is I-type.
{% endhint %}

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-f17e41eb74e2e87d486038bf90befb4e365fdfd3%2Fjalr.png?alt=media" alt=""><figcaption></figcaption></figure>

* `JALR rd, rs1, imm`
  * Reg\[rd] <- PC + 4; PC <- Reg\[rs1] + imm;
    * Write `PC + 4` to Reg\[rd] (_return address_)
    * Sets PC = Reg\[rs1] + offset

{% hint style="warning" %}
Don't need to multiply the immediate by 2.
{% endhint %}

### Adding `JALR` to datapath

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-f64543ee014f6359c681d9e1236660a36df76ae9%2Fdatapath6.jpg?alt=media" alt=""><figcaption></figcaption></figure>

## JAL

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-3cc261016ad9babcc283caa07af7fd881fb29d8a%2Fjal.png?alt=media" alt=""><figcaption></figcaption></figure>

* `JAL rd, imm`
  * Reg\[rd] <- PC + 4; PC <- PC + imm;
    * Write `PC + 4` to Reg\[rd] (_return address_)
    * Sets PC = PC + offset

### Adding `JAL` to datapath

{% hint style="info" %}
What should be added to datapath?
{% endhint %}
