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 为什么不打印X?装配_Assembly_X86_Nasm_Bootloader_Bios - Fatal编程技术网

Assembly 为什么不打印X?装配

Assembly 为什么不打印X?装配,assembly,x86,nasm,bootloader,bios,Assembly,X86,Nasm,Bootloader,Bios,为什么这个程序不打印X?有人能一步一步地解释一下,是什么让它打印一个黑桃作为输出 mov ah, 0x0e ; Set higher bit of ax to 0e (probably the instruction opcode) mov al, the_secret ; Set lower bit of ax to bytes of H int 0x10 the_secret: db 'X' jmp $ ;Jump to the current address forever

为什么这个程序不打印X?有人能一步一步地解释一下,是什么让它打印一个黑桃作为输出

mov ah, 0x0e ; Set higher bit of ax to 0e (probably the instruction opcode)
mov al, the_secret ; Set lower bit of ax to bytes of H
int 0x10

the_secret:
    db 'X'

jmp $ ;Jump to the current address forever

; Padding

times 510 - ($-$$) db 0

dw 0xaa55
。。。要使其打印一个黑桃作为输出

mov ah, 0x0e ; Set higher bit of ax to 0e (probably the instruction opcode)
mov al, the_secret ; Set lower bit of ax to bytes of H
int 0x10

the_secret:
    db 'X'

jmp $ ;Jump to the current address forever

; Padding

times 510 - ($-$$) db 0

dw 0xaa55
。。。现在我真的帮不了你,因为我不知道a的确切十六进制->ASCII值♠️角色。。。不过,我可以帮助您理解如何打印标准(击键)ASCII字符的简单步骤

下面是一个完整的NASM示例,说明如何将字符打印到显示器上;我将把它分解为视频显示特定的块,以帮助您更好地理解该过程(请注意,我在示例中仅使用了实模式组装说明(16位):

我想指出的是,我已经对
push ax
pop ax
进行了注释,因为在这个简单的示例中不需要这些说明。尽管,(主题外)这些指令只是预执行内存堆栈存储(
push
)和/或恢复(
pop
)到
AX
寄存器

mov-ah,0x0E
这很简单。。。它将值
0x0E
分配给
AH
这是
int 0x10
的值

lodsb
这是一种更有效的预成型方法:

mov    al,    BYTE    [SI]           ; Assign Single [BYTE] from [SI] to [AL]
inc    si                            ; Increment [SI] by 1 equivalent to [SI]++
或al,al
检查
[al]
是否等于
0x00
。这是字符流的
NULL
终止字符

jz.output16\u char\u array\u done
如果
[AL]
等于
0x00
,则在
处执行代码。output16\u char\u array\u done
。。。如果
[AL]
等于
0x00
继续执行代码

jmp.output16\u char\u array\u loop
一种不使用
loop
指令循环或迭代某个函数/句柄的简单方法(
loop
需要更多的硬件资源来执行,因此倾向于避免使用此指令,除非它在您的特定环境中更有效)

ret
返回上一个(调用)内存地址的简单指令


int 0x10
这是

我想你想要的
[秘密]
(注意括号)。您还应将DS段寄存器设置为预期值。您没有
ORG
指令,我们也看不到构建引导加载程序的命令,因此我无法确定您应该在DS中输入什么值。如果您将nasm与
-f bin
一起使用,则您的组织将默认为0x0000。在这种情况下,您应该将0x07c0移动到DS,并将类似于
mov ax,0x07c0
mov DS,ax
的内容作为引导加载程序的第一部分。我所说的
[the_secret]
是指指令应该看起来像
mov al[the_secret]
由于您希望在内存地址
中获取字节,然后将其放入AL,而不是将内存地址放入ALAN。如果您的代码中有
ORG 0x7c00
,但在您的问题中没有显示,那么您希望将值
0
放入DS。还有一个问题。您应该将
jmp$
放在数据之前和
int 0x10
之后,否则CPU将尝试执行
密码。
mov    al,    BYTE    [SI]           ; Assign Single [BYTE] from [SI] to [AL]
inc    si                            ; Increment [SI] by 1 equivalent to [SI]++