Help again with printing a message in protected mode
Help again with printing a message in protected mode
[attachment deleted by admin]
Re:Help again with printing a message in protected mode
How come nobodys replying to my post?
Re:Help again with printing a message in protected mode
I have several theories:
1.- because you already post it like three or four times (at least)...and you *got* answers, including code.
2.- on the other hand, posting the code every time you can't do anything sounds too lacy for an os coder.
3.- you asked "How come nobodys replying to my post?" twice.
4.- You start several threads in this forum with the same question.
don't be sad. people has a lot of more important things to do nowadays with all this globalization, internet and stuff
1.- because you already post it like three or four times (at least)...and you *got* answers, including code.
2.- on the other hand, posting the code every time you can't do anything sounds too lacy for an os coder.
3.- you asked "How come nobodys replying to my post?" twice.
4.- You start several threads in this forum with the same question.
don't be sad. people has a lot of more important things to do nowadays with all this globalization, internet and stuff
Re:Help again with printing a message in protected mode
I know the problem! I had the same one...
here is the fixed code ;D
hardware_move_cursor:
pushad ; Save registers
mov ebx,0
mov bl,[yposition] ; Get x offset
mov eax,0
mov al,[xposition]
mov edx,80
mul edx ; Calculate y offset
add ebx,eax ; Calculate index
; select to write low byte of index
mov al,0xf
mov dx,0x03d4
out dx,al
; write it
mov al,bl
mov dx,0x03d5
out dx,al
; select to write high byte of index
mov al,0xe
mov dx,0x03d4
out dx,al
; write it
mov al,bh
mov dx,0x03d5
out dx,al
popad ; restore registers
ret
tell me If i made a bug
here is the fixed code ;D
hardware_move_cursor:
pushad ; Save registers
mov ebx,0
mov bl,[yposition] ; Get x offset
mov eax,0
mov al,[xposition]
mov edx,80
mul edx ; Calculate y offset
add ebx,eax ; Calculate index
; select to write low byte of index
mov al,0xf
mov dx,0x03d4
out dx,al
; write it
mov al,bl
mov dx,0x03d5
out dx,al
; select to write high byte of index
mov al,0xe
mov dx,0x03d4
out dx,al
; write it
mov al,bh
mov dx,0x03d5
out dx,al
popad ; restore registers
ret
tell me If i made a bug
Re:Help again with printing a message in protected mode
Thanks for the help tom, but I still have a problem with it. I now have no cursor at all. What could be the problem, I am using what you posted?
Re:Help again with printing a message in protected mode
i'll get the C code to you later...I know C more than ASM, so i'll let you translate it
Re:Help again with printing a message in protected mode
int cur_cursorX, cur_cursorY;
static unsigned scrwidth, scrheight;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
void start_textmode()
{
cur_cursorX = 0;
cur_cursorY = 0;
scrwidth = 80;
scrheight = 25;
}
void gotoxy( int x, int y )
{
USHORT position = ( y * scrwidth + x );
// cursor LOW port to vga INDEX register
outportb( 0x3D4, 0x0F );
outportb( 0x3D5, ( UCHAR ) ( position & 0xFF ) );
// cursor HIGH port to vga INDEX register
outportb( 0x3D4, 0x0E );
outportb( 0x3D5, ( UCHAR ) ( ( position >> 8 ) & 0xFF ) );
cur_cursorX = x;
cur_cursorY = y;
}
static unsigned scrwidth, scrheight;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
void start_textmode()
{
cur_cursorX = 0;
cur_cursorY = 0;
scrwidth = 80;
scrheight = 25;
}
void gotoxy( int x, int y )
{
USHORT position = ( y * scrwidth + x );
// cursor LOW port to vga INDEX register
outportb( 0x3D4, 0x0F );
outportb( 0x3D5, ( UCHAR ) ( position & 0xFF ) );
// cursor HIGH port to vga INDEX register
outportb( 0x3D4, 0x0E );
outportb( 0x3D5, ( UCHAR ) ( ( position >> 8 ) & 0xFF ) );
cur_cursorX = x;
cur_cursorY = y;
}
Re:Help again with printing a message in protected mode
Does anybody know how to translate this c code into assembly language?
If you do, then please translate it for me in intel syntax assembly.
If you do, then please translate it for me in intel syntax assembly.
Re:Help again with printing a message in protected mode
here:
outportb:
push %ebp
mov %esp,%ebp
mov 0x8(%ebp),%edx
mov 0xc(%ebp),%eax
out %al,(%dx)
pop %ebp
ret
lea 0x0(%esi,1),%esi
init:
push %ebp
mov %esp,%ebp
movl $0x0,0x0
movl $0x0,0x0
movl $0x0,0x0
movl $0x0,0x0
pop %ebp
ret
lea 0x0(%esi),%esi
gotoxy:
push %ebp
mov %esp,%ebp
sub $0x8,%esp
mov 0xc(%ebp),%eax
imul 0x0,%eax
add 0x8(%ebp),%eax
mov %ax,0xfffffffe(%ebp)
sub $0x8,%esp
push $0xf
push $0x3d4
call 82 <gotoxy+0x22>
add $0x10,%esp
sub $0x8,%esp
mov $0x0,%eax
mov 0xfffffffe(%ebp),%al
push %eax
push $0x3d5
call 9b <gotoxy+0x3b>
add $0x10,%esp
sub $0x8,%esp
push $0xe
push $0x3d4
call ad <gotoxy+0x4d>
add $0x10,%esp
sub $0x8,%esp
mov 0xfffffffe(%ebp),%ax
shr $0x8,%ax
and $0xff,%eax
push %eax
push $0x3d5
call cb <gotoxy+0x6b>
add $0x10,%esp
mov 0x8(%ebp),%eax
mov %eax,0x0
mov 0xc(%ebp),%eax
mov %eax,0x0
mov %ebp,%esp
pop %ebp
ret
lea 0x0(%esi),%esi
lea 0x0(%edi,1),%edi
use as to assemble a object file to link into you NASM object file. It was hard enough to make it GAS syntax and I don't know a way to translate it to INTEL
outportb:
push %ebp
mov %esp,%ebp
mov 0x8(%ebp),%edx
mov 0xc(%ebp),%eax
out %al,(%dx)
pop %ebp
ret
lea 0x0(%esi,1),%esi
init:
push %ebp
mov %esp,%ebp
movl $0x0,0x0
movl $0x0,0x0
movl $0x0,0x0
movl $0x0,0x0
pop %ebp
ret
lea 0x0(%esi),%esi
gotoxy:
push %ebp
mov %esp,%ebp
sub $0x8,%esp
mov 0xc(%ebp),%eax
imul 0x0,%eax
add 0x8(%ebp),%eax
mov %ax,0xfffffffe(%ebp)
sub $0x8,%esp
push $0xf
push $0x3d4
call 82 <gotoxy+0x22>
add $0x10,%esp
sub $0x8,%esp
mov $0x0,%eax
mov 0xfffffffe(%ebp),%al
push %eax
push $0x3d5
call 9b <gotoxy+0x3b>
add $0x10,%esp
sub $0x8,%esp
push $0xe
push $0x3d4
call ad <gotoxy+0x4d>
add $0x10,%esp
sub $0x8,%esp
mov 0xfffffffe(%ebp),%ax
shr $0x8,%ax
and $0xff,%eax
push %eax
push $0x3d5
call cb <gotoxy+0x6b>
add $0x10,%esp
mov 0x8(%ebp),%eax
mov %eax,0x0
mov 0xc(%ebp),%eax
mov %eax,0x0
mov %ebp,%esp
pop %ebp
ret
lea 0x0(%esi),%esi
lea 0x0(%edi,1),%edi
use as to assemble a object file to link into you NASM object file. It was hard enough to make it GAS syntax and I don't know a way to translate it to INTEL
Re:Help again with printing a message in protected mode
outportb:
; just use out
init:
cur_cursorX db 0
cur_cursorX db 0
scrwidth dw 80
scwheight dw 25
gotoxy:
pushad ; Save registers
mov ebx,0
mov bl,[cur_cursorX] ; Get x offset
mov eax,0
mov al,[cur_cursorY]; !!!!!!!!!!!!!!!you know asm more so YOU do a y * scrwidth + x
mov edx,80
mul edx ; Calculate y offset
add ebx,eax ; Calculate index
; select to write low byte of index
mov al,0xf
mov dx,0x03d4
out dx,al
; write it
mov al,bl
mov dx,0x03d5
out dx,al
; select to write high byte of index
mov al,0xe
mov dx,0x03d4
out dx,al
; write it
mov al,bh
mov dx,0x03d5
out dx,al
popad ; restore registers
ret
; just use out
init:
cur_cursorX db 0
cur_cursorX db 0
scrwidth dw 80
scwheight dw 25
gotoxy:
pushad ; Save registers
mov ebx,0
mov bl,[cur_cursorX] ; Get x offset
mov eax,0
mov al,[cur_cursorY]; !!!!!!!!!!!!!!!you know asm more so YOU do a y * scrwidth + x
mov edx,80
mul edx ; Calculate y offset
add ebx,eax ; Calculate index
; select to write low byte of index
mov al,0xf
mov dx,0x03d4
out dx,al
; write it
mov al,bl
mov dx,0x03d5
out dx,al
; select to write high byte of index
mov al,0xe
mov dx,0x03d4
out dx,al
; write it
mov al,bh
mov dx,0x03d5
out dx,al
popad ; restore registers
ret
Re:Help again with printing a message in protected mode
I never tried it. I got the original code to work. I re-wrote my bootsector and now the original code works.
I don't know what was happening. It might of been a compatibliity issue.
Thanks for the help!
I don't know what was happening. It might of been a compatibliity issue.
Thanks for the help!
Re:Help again with printing a message in protected mode
BTW, there's one thing your code doesn't address yet: scrolling. However, at this point it probably is a bit early to worry about that.