为什么GNU汇编程序将$用作立即操作数

时间:2018-11-03 12:26:33

标签: assembly x86-64 gnu

传统上,汇编器使用#表示立即数。至少从DEC PDP-11汇编程序开始,这是正确的。可能更长。 这是来自Kermit-11(https://gitlab.com/Rhialto/kermit11/blob/master/k11cvt.mac

的示例
10$:    tst     r1                      ; current state is zero?
        beq     20$                     ; yes, exit then
        clr     r3                      ; get the next ch please
        bisb    (r2)+   ,r3             ; simple
        bic     #^c<177>,r3             ; ensure in range 0..127
        dec     r1                      ; use previous state to get the
        mul     #10     ,r1             ; index into the state table  line
        movb    chtype(r3),r0           ; /BBS/                       column
        add     r0      ,r1             ; add in the character class  line+col
        movb    ptable(r1),r1           ; and get the new state of system
        beq     20$                     ; all done if new state is zero
        bmi     30$                     ; error exit if < 0
        clr     r0                      ; now mask off the action index from
        div     #10.    ,r0             ; the new state
        asl     r0                      ; word indexing to action routine
        jsr     pc      ,@paction(r0)   ; simple
        br      10$                     ; next please

但是,GNU汇编程序似乎使用$

main:
.LFB0:
        pushq   %rbp
        movq    %rsp, %rbp
        movl    %edi, -4(%rbp)
        movq    %rsi, -16(%rbp)
        movl    $0, %eax
        popq    %rbp
        ret

即使$通常用于表示十六进制常量。至少从6502和68000汇编程序开始就是如此。 http://6502.org/source/games/uchess/uchess.htm中的随机示例:

; 6551 I/O Port Addresses
;
ACIADat =   $7F70
ACIASta =   $7F71
ACIACmd =   $7F72
ACIACtl =   $7F73

8x86指令通常(首先是目标操作数,第二是源操作数)(这让我非常烦恼,因为我习惯了另一种方式)。但是用于x86 / x86_64代码的GNU汇编器交换操作数顺序。请参阅movl $0, %eax,否则将没有任何意义。

另外(例如,请参见* in front of instruction operand, GNU assembly, AMD64),GNU汇编器使用*而不是@来指示第二级间接访问(比较PDP-11 jsr pc,@paction(r0)

为什么GNU汇编器违反所有这些标准?

0 个答案:

没有答案
相关问题