Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.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 使用bios中断0x10打印字符串_Assembly_Nasm_X86 16_Bios - Fatal编程技术网

Assembly 使用bios中断0x10打印字符串

Assembly 使用bios中断0x10打印字符串,assembly,nasm,x86-16,bios,Assembly,Nasm,X86 16,Bios,我想使用bios中断0x10打印字符串。但我只有一个蓝色的封套,里面没有字母。也许我在处理我的字符串时遇到了问题 [BITS 16] org 0x5000 sect2: mov ah, 0x03 ;get curser position mov bh, 0x00 ;page number int 0x10 mov ax, 0x0500 mov es, ax mov bp, bsy1msg mov ah, 0x13

我想使用bios中断0x10打印字符串。但我只有一个蓝色的封套,里面没有字母。也许我在处理我的字符串时遇到了问题

[BITS 16]
org 0x5000

sect2:
    mov ah, 0x03    ;get curser position
    mov bh, 0x00    ;page number

    int 0x10

    mov ax, 0x0500 
    mov es, ax
    mov bp, bsy1msg 

    mov ah, 0x13            ;write string
    mov al, 0x01            ;update cursor after writing
    mov bh, 0x00            ;page number
    mov bl, 0x1F            ;atributes
    mov cx, bsy1len         ;number of characters in string

    int 0x10

end:
    jmp end

bsy1msg db 13,10,"BSY1 via INT 0x10"
bsylen equ $ - bsy1msg
编辑:我有两个代码文件。第一个写在软盘的第一个扇区上。它将第二个扇区从软盘复制到内存(从0x5000开始),然后跳转到0x5000。这是我的第二个文件,我应该在这里打印我的字符串

[BITS 16]
org 0x5000

sect2:
    mov ah, 0x03    ;get curser position
    mov bh, 0x00    ;page number

    int 0x10

    mov ax, 0x0500 
    mov es, ax
    mov bp, bsy1msg 

    mov ah, 0x13            ;write string
    mov al, 0x01            ;update cursor after writing
    mov bh, 0x00            ;page number
    mov bl, 0x1F            ;atributes
    mov cx, bsy1len         ;number of characters in string

    int 0x10

end:
    jmp end

bsy1msg db 13,10,"BSY1 via INT 0x10"
bsylen equ $ - bsy1msg

org
指令不会导致在特定的物理地址加载程序,它会通知汇编程序假定程序加载到代码段那么远

例如,
sect2
的值不是零,而是
0x5000

es
设置为
0x500
将使其从物理地址
05000
启动,但程序不在该地址。您希望额外的段从与代码段相同的点开始,因为
bsy1msg
标签相对于代码段(如果计算正确,则其值为
0x501d


地址表示为
段:偏移量
,物理地址计算为
段*16+偏移量
。因此
0x0500:0
引用与
0:0x5000
相同的物理地址。如果您的程序位于物理地址0x5000,则
CS:IP
应为
0x0500:0
0:0x5000
。该字符串位于物理地址0x501d处。由于您指定了
org 0x5000
nasm将假定bsy1msg的偏移量为0x501d。这意味着该段必须为0(
0*16+0x501d=0x501d
)。或者,如果您将ES设置为0x0500(直接或通过复制CS),则需要省略org 0x5000或从BP中减去偏移量(
mov BP,bsy1msg-sect2
),以获得正确的物理地址(
0x0500*16+0x001d=0x501d
)。

尝试使用
mov ax,CS
而不是该常量来加载ES。我不完全相信你的假设是正确的。使用'mov ax,cs'我得到了相同的结果可能是'org 0x5000'的结果?确定DH/DL(行/列)有正常值吗?我的程序是0x5000。作为一个完全的初学者,我忘了把这个添加到我的问题中。@spitzbuaamy:那么
es
应该仍然与
cs
相同,即零。