中断10小时不工作 [英] Interrupt 10h not working
问题描述
我在节目中得到段错误的下面。结果
这是为了设置在屏幕的左上角的光标。但是,为什么我对这个节目越来越细分的错吗?
感谢您的答复。
I am getting segmentation fault in the program below.
This is for set the cursor on the top-left of the screen. But why i am getting segmentation fault on this program?
Thanks for the replies.
section .text
global main
main:
mov ah, 2
mov bh, 1
mov dh, 0
mov dl, 0
int 10h
我觉得现在的问题是,我工作的保护模式。这是一个16位指令,我在32位机上尝试这个!我是正确的?
I think that the problem is the protected mode that i am working. This is an 16-bit instruction and i am trying this in a 32-bit machine! Am i correct?
我运行此程序在Linux Ubuntu发行版32位。该处理器是AMD C-60。
I am running this program in a Linux Ubuntu distribution 32-bits. THe processor is AMD C-60.
推荐答案
BIOS中断16位code。您的操作系统已经把CPU的32位保护模式。硬件将允许切换回16位实模式(有跳火圈通过),但OS不会允许它。不会很保护,如果它做到了。它是由美国的保护,我的朋友!
BIOS interrupts are 16-bit code. Your OS has put the CPU in 32-bit protected mode. The hardware will allow a switch back to 16-bit real mode (there are hoops to jump through) but the OS won't allow it. Wouldn't be very "protected" if it did. It is "protected" from US, my friend!
我想你可能想看看是VT100终端仿真。按理说,一个强有力的计划将征询的termcap文件,以确保VT100仿真是尝试使用它之前可用。我的经验是,它的通常提供一个桌面Linux中,所以我只是假设它的存在。最坏的可能发生(我认为)是在屏幕上的垃圾,如果我们假设是错误的。
I think what you probably want to look into is "vt100" terminal emulation. By rights, a "robust" program would consult the "termcaps" file to make sure vt100 emulation is available before attempting to use it. My experience is that it's "usually" available on a "desktop Linux" box, so I just ASSume it's there. Worst that can happen (I think) is garbage on the screen if we ASSume wrong.
这个例子没有做的正是你想要的。它保存当前光标位置(上帝知道在哪里),将光标移动到新的位置,显示一条消息,并返回到原来的光标位置。你需要查找家指针命令(ESC [H?lookitup)。只是把它写到标准输出,一样的hello world。你可以得到的颜色和东西了。
This example doesn't do exactly what you want. It saves the current cursor position (lord knows where), moves the cursor to a new position, prints a message, and goes back to the original cursor position. You'll need to look up the "home cursor" command ("ESC [h"? lookitup). Just write it to stdout, same as "hello world". You can get colors and stuff, too.
; nasm -f elf32 mygem.asm
; ld -o mygem mygem.o -melf_i386
global _start
section .data
savecursor db 1Bh, '[s'
.len equ $ - savecursor
unsavecursor db 1Bh, '[u'
.len equ $ - unsavecursor
getcursor db 1Bh, '[6n'
.len equ $ - getcursor
setcursor db 1Bh, '[10;20H'
.len equ $ - setcursor
msg db "Hello, new cursor position!"
.len equ $ - msg
section .text
_start:
mov ecx, savecursor
mov edx, savecursor.len
call write_stdout
mov ecx, setcursor
mov edx, setcursor.len
call write_stdout
mov ecx, msg
mov edx, msg.len
call write_stdout
mov ecx, unsavecursor
mov edx, unsavecursor.len
call write_stdout
exit:
mov eax, 1
xor ebx, ebx
int 80h
;------------------------
write_stdout:
push eax
push ebx
mov eax, 4
mov ebx, 1
int 80h
pop ebx
pop eax
ret
;---------------------
这篇关于中断10小时不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!