Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 打印字符x86程序集_Assembly_X86 - Fatal编程技术网

Assembly 打印字符x86程序集

Assembly 打印字符x86程序集,assembly,x86,Assembly,X86,下面是我的一些代码: .data testString: .ascii "Test String\0" .text .global _start .code16 _start: movl testString, %si movb (%si), %al call printChar jmp _exit printChar: movb $0x0E, %ah

下面是我的一些代码:

.data
    testString:
        .ascii "Test String\0"

.text
    .global _start

    .code16

    _start:
        movl testString, %si

        movb (%si), %al
        call printChar
        jmp _exit

    printChar:
        movb $0x0E, %ah
        movb $0x07, %bl
        int $0x10
        ret

    _exit:
        ...
我想做的是将字符串的指针移动到si寄存器中,这样我就可以使用如下方式打印每个字符:

增量%si


我做错什么了吗?谢谢

您需要
movw$testString,%si
将地址加载到
si
中。我假设您知道如何处理16位代码和bios中断,并且不想在32位操作系统(如linux)下运行它。为什么要使用movw?movl不移动64位地址吗?
movl
是32位,
movw
是16位
movq
将为64位。您正在编写16位代码(无论出于何种原因)。之所以编写16位代码,是因为他没有处于实模式,因为这是一个引导程序(如他正在执行
int 0x10
这一事实所示)