NASM x86组件的$$有什么作用?

时间:2018-06-23 18:04:18

标签: x86 nasm x86-64 boot

我对计算机如何启动非常好奇,因此我在网上找到了一些自学的资源。我从一本gitbook中找到了它,并提出了一些问题。我继续并注释了代码段

[BITS 16]

boot:
    mov al, '!'
    mov ah, 0x0e
    mov bh, 0x00
    mov bl, 0x07 ;What are these parameters to the interrupt call?

    int 0x10 ;Bios interrupt call
    jmp $ ;<---- jmp $ means jump here, will this be an infinite loop?
    ;^ Or will this continue onto all the 0 bytes?

times 510-($-$$) db 0 ;<---- declare 510-($-$$) 0 bytes. What is $$?

;Here we have the two magic bytes to end
db 0x55
db 0xaa

我尝试在NASM文档中查找$$和此处的内容,但仅在$上找到了文档。这是我到目前为止所拥有的。拆卸编译后的程序集时,我注意到了几件事。

   00000000 <.data>:
   0:   b0 21                   mov    al,0x21 ;Character to type out
   2:   b4 0e                   mov    ah,0xe  ;Sets mode to teletype
   4:   b7 00                   mov    bh,0x0  ;Unused?
   6:   b3 07                   mov    bl,0x7  ;Color
   8:   cd 10                   int    0x10 ;syscall with ^ params
   a:   eb fe                   jmp    0xa ;Infinite loop?
    ...
 1fc:   00 00                   add    BYTE PTR [bx+si],al
 ;0x1fe - 0xa = 500 bytes, so times 510-($-$$) = 500?
 1fe:   55                      push   bp 
 1ff:   aa                      stos   BYTE PTR es:[di],al

任何帮助将不胜感激,谢谢。

0 个答案:

没有答案