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.
Hiya, again I have a problem with my OS. I have a ClrScn program that clears the screen by putting multiple spaces, 1920 (24 lines x 80 columns) to be exact, onto the screen.
clearscr:
push cx
push es
push di
push ax
mov cx, 0xb800 ; set up the video memory segment
mov es, cx
mov di, 0 ; starting location (upper left corner)
mov ax, 0x0720 ; ASCII <space> character
mov cx, 0x1920 ; # of chars on the screen (80x24)
rep stosw
mov byte [cursor],0 ; move cursor to the top of the screen
call set_hwcursor
pop ax
pop di
pop es
pop cx
ret
(set_hwcursor is a function that sets the hardware cursor)
However, it doesn't work. It clears the screen alright, but it doesn't reset the cursor's position, even though it calls set_hwcursor to reset it. I know that set_hwcursor works because I use it in my video driver.
Any help would be appreciated.
Thanks!
phillid - Newbie-ish operating system developer with a toy OS on the main burner
mov byte [cursor],0 ; move cursor to the top of the screen
How can the cursor (both the row and the column) fit in a single byte?
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
phillid wrote:However, it doesn't work. It clears the screen alright, but it doesn't reset the cursor's position
Let me get this straight: you name your post "ClrScn Funtion not working", while clearing the screen works fine, then tell us it's the positioning of the cursor that goes wrong, while not showing the cursor positioning code but instead the, working, clear screen code????? Jeez...
; -----------------------------------------------------
; Set the hardware cursor position
;
set_hwcursor:
push ax
push dx
mov dx, 0x3D4
cli ; disable interrupts
mov al, 14 ; register 14-15 set the cursor pos
out dx, al ; video controller
mov ax, [cursor] ; get our s/w cursor position
shr ax, 1 ; / by 2 to get cursor position
shr ax, 8 ; get the high byte
; and ax, 0xFF
add dx, 1
out dx, al
mov al, 15
sub dx, 1
out dx, al
mov ax, [cursor]
shr ax, 1 ; / by 2 to get cursor position
; and ax, 0xFF ; get the low byte
add dx, 1
out dx, al
sti
pop dx
pop ax
ret
phillid - Newbie-ish operating system developer with a toy OS on the main burner
That's what you get for stealing code and not using it correctly. [cursor] is 16 bits, you write 8 which is wrong as Brendan already guessed.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
neon wrote:It is heavily documented if you know where to look. Seriously.
It's heavily documented, if you're willing to make the assumption that the hardware is VGA compatible (rather than just having "VGA compatible int 0x10" and no hardware compatibility).
I look forward to the day that video card manufacturers are free to implement nice, clean/elegant hardware; without any market pressure to mangle their design to emulate obsolete crud. Unfortunately, getting rid of the crusty old crud is very difficult for hardware manufacturers to do, especially when people are still writing new software that relies on compatibility with something that hasn't made sense for a few decades.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Brendan wrote: It's heavily documented, if you're willing to make the assumption that the hardware is VGA compatible (rather than just having "VGA compatible int 0x10" and no hardware compatibility).
I look forward to the day that video card manufacturers are free to implement nice, clean/elegant hardware; without any market pressure to mangle their design to emulate obsolete crud. Unfortunately, getting rid of the crusty old crud is very difficult for hardware manufacturers to do, especially when people are still writing new software that relies on compatibility with something that hasn't made sense for a few decades.
Cheers,
Brendan
In those days, BIOS manufacturers too will start dropping VGA support and probably implement some new standard.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Chandra wrote:In those days, BIOS manufacturers too will start dropping VGA support and probably implement some new standard.
I'm still hoping that one day everyone will switch to something like UEFI, and everyone can get rid of a lot of stupid legacy crud (A20 gate!) after that. Then we'd only need to worry about stupid modern crud...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Combuster wrote:That's what you get for stealing code and not using it correctly. [cursor] is 16 bits, you write 8 which is wrong as Brendan already guessed.
I didn't steal the code, it was givien to me with the intentions of temporary use.
Noob question: how would I write 16 bits to [cursor]? (this could have been said in an earlier post)
phillid - Newbie-ish operating system developer with a toy OS on the main burner
clearscr:
push cx
push es
push di
push ax
mov cx, 0xb800 ; set up the video memory segment
mov es, cx
mov di, 0 ; starting location (upper left corner)
mov ax, 0x0720 ; ASCII <space> character
mov cx, 0x1920 ; # of chars on the screen (80x24)
rep stosw
mov byte [cursor],0 ; move cursor to the top of the screen
call set_hwcursor
pop ax
pop di
pop es
pop cx
ret
clearscr:
push cx
push es
push di
push ax
mov cx, 0xb800 ; set up the video memory segment
mov es, cx
mov di, 0 ; starting location (upper left corner)
mov ax, 0x0720 ; ASCII <space> character
mov cx, 0x0780 ; # of chars on the screen (80x24)
rep stosw
mov word [cursor], 0 ; move cursor to the top of the screen
call set_hwcursor
pop ax
pop di
pop es
pop cx
ret
trinopoty wrote:You have to replace [some code] with [some code]
Apart from the fact that there's only a single change, in a single line that could easily have been communicated in a better format than a copy/paste of an entire routine with one change, this doesn't teach anyone anything.