纯DOS下汇编运行问题

eric_geng 2008-03-11 02:44:15
.model small
.code
org 100h
start:
mov ax, 0012h
int 10h ;set display mode

mov bx, 0001h
mov ah, 0bh
int 10h ;set Palette
end

上面这段代码,为什么在运行时提示 CPU error: incorrect opcode 这样的提示呢?
哪位达人能回答一下,有人说 要注释掉Dos下auto文件的带killer行,但我注释掉后发现
死机,不知道时什么原因?
...全文
244 11 打赏 收藏 举报
写回复
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
当执行汇编程序时,总是从end后所接的标号开始执行 例如:
.model small
.code
org 100h
start1:
mov ax, 0012h
int 10h ;set display mode
start2:
mov bx, 0001h
mov ah, 0bh
int 10h ;set Palette
end start2

该程序在编译,连接时都不会出错,但执行时是从start2:开始执行,也就是程序只执
start2:
mov bx, 0001h
mov ah, 0bh
int 10h ;set Palette
end start2
这一段代码
疯哥哥 2008-03-13
  • 打赏
  • 举报
回复
我帮楼上解释一下吧,
你编写的是com程序.这个跟com程序加载,程序段前缀PSP有关.自己google一下.
com程序可以int 20返回.
也可以
mov ax,4c00h
int 21返回,
也可以像mydo所说那样.后两个方法对exe也适用
eric_geng 2008-03-11
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 mydo 的回复:]
push ds
xor ax,ax
push ax

;your code is here
retf
[/Quote]

能解释一下吗?
eric_geng 2008-03-11
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 mydo 的回复:]
Assembly codepushdsxorax,axpushax;your code is hereretf
[/Quote]

能解释一下吗?
cnzdgs 2008-03-11
  • 打赏
  • 举报
回复
DOS程序运行完后,是要退回DOS系统,BIOS当然没有这种功能。不过你如果掉int 0(除法异常),因为DOS接管了这个中断,也可以退出程序返回DOS。
大熊猫侯佩 2008-03-11
  • 打赏
  • 举报
回复

push ds
xor ax,ax
push ax

;your code is here

retf
eric_geng 2008-03-11
  • 打赏
  • 举报
回复
如果不用DOS中断,bios中断有没有类似.exit或4c号中断相同功能的中断呢
大熊猫侯佩 2008-03-11
  • 打赏
  • 举报
回复
必须手动写返回指令。
cnzdgs 2008-03-11
  • 打赏
  • 举报
回复
初学者很多人认为:“END表示程序结束,程序执行到END就结束了”,实际上END是伪指令,是给汇编器看的,程序中必须有退出程序的指令。DOS程序一般用int 21H的4CH号功能退出。
BAYNPU 2008-03-11
  • 打赏
  • 举报
回复
.exit 少了这一个句,程序无法返回操作系统.
end
智能卡_Snooper 2008-03-11
  • 打赏
  • 举报
回复
你程序结束后没返回dos吧

.model  small 
.code
org 100h
start:
mov ax, 0012h
int 10h ;set display mode

mov bx, 0001h
mov ah, 0bh
int 10h ;set Palette
mov ah, 4ch
int 21h
end
相关推荐
发帖
汇编语言

2.1w+

社区成员

汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
帖子事件
创建了帖子
2008-03-11 02:44
社区公告
暂无公告