News for hackers. Stuff that matters.
Re:What was the original reason for the design of AT&T assem... by souprock on Saturday February 13, 2021 @08:16PM (#26128761)
For the jmp instruction, both source and destination are the rip register. That other thing is an immediate value. Really jmp is just mov or add, with the rip register. Like so:

    movq somelabel, %rip
    addq somelabel-%rip, %rip

    mov rip, _somelabel
    add rip, _somelabel-rip
Re:What was the original reason for the design of AT&T assem... by ksaj on Sunday February 14, 2021 @03:04AM (#26130503)
It was never legal to jump that way, though. And it wouldn't make sense if it was allowed by the cpu for your jump source to be somewhere you haven't been yet. So the $ "here" makes more sense, at least to me. Literally "from here, to there" versus "from there, to there."

Here's a similar "illegal" re-envisioning of a call:

      push rip
      mov  rip, _interrupt  ; a weird illegal jump
      ...
    _interrupt:
      ...
      pop rip    ; similarly illegal way to RET
The workings are the same, but the cpu won't let you write it that way of course. The source and destination are still clear and intact because you start by pushing the source onto the stack before giving the destination, so it's at least good for demonstrating that bit of near-consistency in the Intel syntax.

Part of the reason these rip shenanigans aren't allowed is because you'd have a hell of a time jumping or calling to a different SEG (segment), as INT always does, and the jumps can do if you need them to, because you'd have to push change the index pointer and the segment at the same time somehow. So you'd be limited to .COM (single segment memory images) file format with no interrupts if that's how you wanted to go about doing them. Simply "editing" rip, if you could, would stick you to a single memory segment.