Page 1 of 1

cursor doesnt move...am i missing something?

Posted: Fri Aug 03, 2007 7:42 pm
by sancho1980
hi

i've started coding a minimal kernel in hla (http://webster.cs.ucr.edu/)..i have a routine to write to the screen (in pm, i.e. writing to video memory) and i also have a cursor varibale to track the position of the next character to be printed to screen. now i was trying to write the move_cursor procedure and found that it doesnt work:

Code: Select all

procedure move_cursor;
begin move_cursor;
	pusha();
	pushf();

	mov(cursor,cx);

	mov(cx,dx);
	shr(8,dx);
	mov($3D4,eax);
	out(eax,14);
	mov($3D5,eax);
	out(eax,dx);

	movzx(cl,dx);
	mov($3D4,eax);
	out(eax,15);
	mov($3D5,eax);
	out(eax,dx);
	

	popf();
	popa();
end move_cursor;
but no matter how often i call this routine, the cursor always stays at the same position. before switching to pm i made a teletype output with an interrupt which left the cursor somewhere in the middle of the display so i can clearly see it, but my procedure doesnt make any changes to that position? is there a trick? (the cursor is NOT blinking..might that mean it is frozen or something and needs activating via some special port first???)

thanks

martin

Posted: Fri Aug 03, 2007 9:23 pm
by SpooK
Here is an snippet from my routine...

Code: Select all

	mov	edx,0x03D4	 ;VGA Index Register
	mov	eax,0x0E0F	 ;Commands
	out	dx,al			;Send "Set LOW" Command
	inc	edx
	mov	al,cl
	out	dx,al			;Send LOW BYTE
	dec	edx
	mov	al,ah
	out	dx,al			;Send "Set HIGH" Command
	inc	edx
	mov	al,ch
	out	dx,al			;Send HIGH BYTE
HtH :)

Posted: Fri Aug 03, 2007 10:50 pm
by pcmattman
By the way, the 'blinking cursor' is dependent on the computer you run it on. Most PCs will use a blinking cursor, Bochs won't blink, Virtual PC blinks, QEMU doesn't blink (uses same BIOS as Bochs).

Here's my cursor move routine (I'm sure it should be simple to convert to assembly):

Code: Select all

/// Moves the cursor to the x and y member values
void Console::MoveCursor()
{	
	// offset
	short offset = m_x + ( m_y * 80 );
	
	// make sure that the cursor shows up as white (change the '7' to any other number under 0xF for a trippy cursor)
	*(unsigned short*) ( 0xB8000 + ( offset * 2 ) ) = ( 0x07 << 8 ) | ' ';
	
	// cursor offset, low byte to vga index reg
	outportb( 0x3D4, 0x0F );
	outportb( 0x3D5, (unsigned char) offset & 0xFF );
	
	// cursor offset, high byte to vga index reg
	outportb( 0x3D4, 0x0E );
	outportb( 0x3D5, (unsigned char) ( offset >> 8 ) & 0xFF );
}

Posted: Sat Aug 04, 2007 2:12 am
by sancho1980
honestly i dont see the problem, as far as i see, my routine does exactly the same as yours..except i forget to set the attribute of the cursor..but the very fact that the cursor STAYS at the same position tells me that this is not the problem!

edit: SpooK, i just converted your routine into hla and it works...dont know whats the problem with mine though :-(
looks like this now:

Code: Select all

procedure move_cursor;
begin move_cursor;
	pusha();
	pushf();
	mov(cursor,cx);

	mov($03D4,edx);
	mov($0E0F,eax);
	out(al,dx);
	inc(edx);
	mov(cl,al);
	out(al,dx);
	dec(edx);
	mov(ah,al);
	out(al,dx);
	inc(edx);
	mov(ch,al);
	out(al,dx);

	popf();
	popa();
end move_cursor;

Posted: Mon Aug 06, 2007 12:21 am
by os64dev
edit: SpooK, i just converted your routine into hla and it works...dont know whats the problem with mine though
Well for starters in your code you write EAX(32 bits) to the outport while spooks code write AL(8 bits) and only the latter is the correct version. If you write to ports use the bitdepth they specify otherwise you possibly overwrite the next port.