cursor doesnt move...am i missing something?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

cursor doesnt move...am i missing something?

Post 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
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post 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 :)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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 );
}
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

Post 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;
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
Post Reply