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
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?
I am running this program in a Linux Ubuntu distribution 32-bits. THe processor is AMD C-60.
Try the following:
Please read this:
For linux you should work only with system calls this is a well documented tutorial, you put in
eax
the number of the sys call and jump to it/ switch into kernel mode withint 80h
: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!
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.
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.