RISC-V Assembly Code #4: Asm Directives, Pseudo Instructions

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 9

  • @shanehebert396
    @shanehebert396 Месяц назад +1

    Another benefit of pseudo instructions is that it reduces the number of mistakes. It'll always get the correct instructions, like the imm20 vs. imm12 are calculated and used correctly with the correct real instructions.

  • @zayn7510
    @zayn7510 Месяц назад +1

    Great

  • @Eidolon2003
    @Eidolon2003 Месяц назад +2

    I really appreciate these videos!
    I have one question with regard to pseudo instructions. In the case of a long jump, you showed
    j imm32
    becomes
    lui t0, imm20
    jalr zero, imm12(t0)
    Does this mean that whenever a 'j' or 'call' pseudo-instruction is used you have to assume t0 is clobbered? Are there any other pseudo-instructions that could clobber registers?

  • @SkYhAwKxInD
    @SkYhAwKxInD Месяц назад +1

    .align will align data of the next directive to the requested boundary. Only power of 2 values are allowed, e.g.:
    a: .byte 0x00
    .align 4
    b: .word 0x12345678
    will align the 4 byte (word) value accessible by the label b to the next address which is divisible by 4. The gap between label a and b, if any, will be filled either with zeros or in some architecture implementation with the value for the "nop" instruction.

    • @hhp3
      @hhp3  Месяц назад

      Yes, that’s what you’d think. But for my system, something is not working… computers!?!?!

  • @plh256
    @plh256 Месяц назад

    At 7:10 the problem is that you need the length of the program not to change depending on things you haven't seen yet. The simple assemblers I have written are two pass and the first pass works out the label values. So any pseudo instruction needs to have a known length when you process it.

  • @marouaniAymen
    @marouaniAymen Месяц назад

    There is a VS Code extension that runs RISC-V assembly code, I'll run the explained instruction in order to understand them better.