Skip to content

Incorrect instruction encoding for JAL #89

@charlesdaniels

Description

@charlesdaniels

Minimal test case:

jal x1 l1
l1:
nop

This assembles to:

 Address    Code        Basic                     Source

0x00000000  0x004000ef  jal x1,0x00000002     1    jal x1 l1
0x00000004  0x00000013  addi x0,x0,0x00000000 3    nop

(This is compact .text at 0, but it doesn't matter since JAL is relative)

However, according to the spec on page 16, the low order bit of the immediate value is placed at index 21. This would imply the instruction should be encoded as 0x002000ef -- noting that 0x002000ef & (1 << 21) >> 21 = 1. Also note that JAL technically has a 21-bit immediate, but the lowest order bit is omitted as described on page 15, thus a a relative jump to PC+2 should have a single 1 in the lowest order bit of the immediate.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions