最简单的汇编软盘引导系统helloworld的问题

来源:百度知道 编辑:UC知道 时间:2024/07/08 12:12:02
;***********************************************************
;helloworld
;Gerry
;***********************************************************
.model small
;***********************************************************
.stack
;***********************************************************
.code[codeseg]
;main programe
main proc far
org 07c00H ;make & = 07c00h

mov ax,07c0h
mov ds,ax
mov es,ax ; initialize all the segment to the same

;hello world
string db 'hello world'
len equ $-string
mov ah,3
mov bh,0
int 10H
mov bp,seg string
mov es,bp
mov bp,offset string
mov cx,len
mov bl,01H
mov dh,15
mov dl,0
mov al,1
mov ah,13H
int 10H
jmp $
exit:
mov ax,4c00H
int 21H
main endp
;---------------------------------------------------------------
end main

不懂X86汇编和结构的人答
mov ax,07c0h
mov ds,ax
mov es,ax ; initialize all the segment to the same
string db 'hello world'
len equ $-string
mov ah,3
mov bh,0

你在 mov ah,3 这种语句前面定义 helloworld是不是有问题啊
如果这样感觉上应该是 运行
mov es.ax;这个设置目的寄存器后就运行 'hello world'的机器码
二不是跳到你想要的 mov ah,3这个地方去

感觉上如果想要能用这么也要..在上面写个 跳转或者
直接在代码的最后面定义 db 'hello world'
至少非x86的汇编好像都是这样

把数据定义参放在指令段之间是许多汇编初学者易犯的常识性错误,是个很不好的习惯。试想,在执行完

mov ax,07c0h
mov ds,ax
mov es,ax

之后,往下在执行什么呢?电脑不知道下面的内容是你定义的数据,结果把定义的数据当作指令来执行,岂不乱套?

前两楼说的都不错 但是我觉得 为什么是obj用nasm直接生成com不更好?