Assembly (x86):

后端 未结 2 665
醉话见心
醉话见心 2021-01-22 00:18

I\'ve been banging my head against the wall in an attempt to understand why the following assembly is not correctly dumping the contents of \'HELLO_WORLD\'.

<         


        
2条回答
  •  滥情空心
    2021-01-22 00:47

    Since you're creating a boot sector the execution begins at the first byte of the generated file. It won't begin at the start label or anywhere else. Since the string "hello world" is at the start of the file these bytes are what get executed first. These bytes are interpreted by the CPU as instructions, not characters, and they get executed as whatever instructions they get decoded as.

    Here are the instructions that get executed:

    7c00:   68 65 6c                push   0x6c65
    7c03:   6c                      ins    BYTE PTR es:[di],dx
    7c04:   6f                      outs   dx,WORD PTR ds:[si]
    7c05:   20 77 6f                and    BYTE PTR [bx+0x6f],dh
    7c08:   72 6c                   jb     0x7c76
    7c0a:   64 00 be 00 7c          add    BYTE PTR fs:[bp+0x7c00],bh
    7c0f:   e8 02 00                call   0x7c14
    7c12:   eb fe                   jmp    0x7c12
    7c14:   8a 04                   mov    al,BYTE PTR [si]
    ...
    

提交回复
热议问题