Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

RISC-V is even more fun where they shift based on shamt[4:0] (or [5:0] in XLEN=64 mode). So, if you do something like:

    li    t0, 128
    li    t1, 1
    sll   t2, t1, t0
You'll get t2 := 1 since t0[5:0] == 6'b0 (i.e. no shift). It's a very sensible solution IMO if you don't have trapping arithmetic since you don't have to do anything special to handle illegal shifts, it just works.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: