My print string function
Re:My print string function
Ok, thanks.
When i get those functions working i will upload it so that u can see (correct and comment) what i have done.
/ Christoffer
When i get those functions working i will upload it so that u can see (correct and comment) what i have done.
/ Christoffer
Re:My print string function
Might I add a suggestion for your assembly skills?
When you call a function in the usual ABI (not sure how you call it, the one on 32-bit linux at least, and probably 32-bit windows as well) you have to save all registers but EAX, and EAX is, for integer returns, *always* used. Even in void functions you can wreck EAX.
This saves a lot of useless movs and pushes/pops
Grtz, Candy
When you call a function in the usual ABI (not sure how you call it, the one on 32-bit linux at least, and probably 32-bit windows as well) you have to save all registers but EAX, and EAX is, for integer returns, *always* used. Even in void functions you can wreck EAX.
This saves a lot of useless movs and pushes/pops
Grtz, Candy
Re:My print string function
Ok, thanks...
Re:My print string function
I am back! About 6 months of php-programming have passed since my last visit, but now i am back and i will ask stupid questions until i get this working...
Candy, could you be so kind to take another look at this file (slightly cleaned up), and remind me of what stupid misstake i have done?
/ Christoffer
Candy, could you be so kind to take another look at this file (slightly cleaned up), and remind me of what stupid misstake i have done?
/ Christoffer
Re:My print string function
What's that you're doing there? It looks as if you're in 32-bit pmode there. Are you programming the video card directly using the processor's I/O address space? Where did you get the information to do that? Thanks!
Re:My print string function
Strictly speaking a VGA CRTC, whereas not all modern video cards emulate that. Or so I've heard, didn't test a thing graphical yet.
Re:My print string function
i did some more cleaning in the code yesterday, here it is.
can somebody show me there (asm) functions for getcursorxy and/or print_char, so i can compare?
screenshots: http://bubach.1go.dk/os/
can somebody show me there (asm) functions for getcursorxy and/or print_char, so i can compare?
screenshots: http://bubach.1go.dk/os/
Re:My print string function
Hi,
- which routines are called by other code?
- what is each segment register normally set to?
- what's more important, speed or size?
- what's the oldest CPU you support?
Cheers,
Brendan
Answer these questions and I'll rewrite/optimize your code:bubach wrote: i did some more cleaning in the code yesterday, here it is.
can somebody show me there (asm) functions for getcursorxy and/or print_char, so i can compare?
- which routines are called by other code?
- what is each segment register normally set to?
- what's more important, speed or size?
- what's the oldest CPU you support?
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.
Re:My print string function
Oh, i don?t care that much about optimization. The reason i "cleaned" it up was becasue the code looked like **** with for example both tabbing and spaces mixed.
The problem is that it doesn?t work. I think that is the getcursorxy and/or print_char function that is buggy.
The problem is that it doesn?t work. I think that is the getcursorxy and/or print_char function that is buggy.
Re:My print string function
Hi,
I couldn't find anything wrong with getcursorxy, but print_char is a bit messed up. Try this:
Cheers,
Brendan
Sorry - I didn't realize it was still buggybubach wrote: Oh, i don?t care that much about optimization. The reason i "cleaned" it up was becasue the code looked like **** with for example both tabbing and spaces mixed.
The problem is that it doesn?t work. I think that is the getcursorxy and/or print_char function that is buggy.
I couldn't find anything wrong with getcursorxy, but print_char is a bit messed up. Try this:
Code: Select all
; Print char. IN: bl = char, bh = attrib
;----------------------------------------
print_char: pushad
push es
push ebx
call getcursorxy
cmp dh, 80
jb .l1
inc dl
xor dh, dh
.l1:
cmp dl, 25
jb .l2
call scroll_up
.l2:
call getcursor
movzx eax, bx
pop ebx
mov [es:(eax*2 + 0xb8000)], bx
pop es
popad
ret
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.
Re:My print string function
It looks alot better! Thanks.
Now to see if that fixes the problem...
Now to see if that fixes the problem...
Re:My print string function
Finally i got print_char working.
The function is slightly modified from the one you gave me:
that code seems to work fine, but the print string function is really wierd, it clears the screen and goes wild with the cursor on the bottom of the screen.
this is how it looks:
i have also tried the most basic version, like this:
with the same result.
any idea what could be wrong?
The function is slightly modified from the one you gave me:
Code: Select all
; Print char. IN: bl = char, bh = attrib
;----------------------------------------
print_char:
pushad
push es
push ebx
call getcursorxy
cmp dl, 25
jb .l1
cmp dh, 80
jb .l1
call scroll_up
.l1:
call getcursor
call inccursor
movzx eax, bx
pop ebx
mov [es:(eax*2 + 0xb8000)], bx
pop es
popad
ret
this is how it looks:
Code: Select all
; Display a asciiz message on the screen.
; Input: SI = Message, AL = COLOR.
;--------------------------------------------
print:
pushad
mov bh, al
.DisplayChar:
lodsb
or al, al
jz .Done
cmp al, 0x0D
je .Enter
cmp al, 0x0A
je .DisplayChar
mov bl, al
call print_char
jmp .DisplayChar
.Enter:
call getcursorxy
mov dh, 0x00
inc dl
call setcursorxy
jmp .DisplayChar
.Done:
popad
ret
Code: Select all
; Display a asciiz message on the screen.
; Input: SI = Message, AL = COLOR.
;--------------------------------------------
print:
pushad
mov bh, al
.DisplayChar:
lodsb
or al, al
jz .Done
mov bl, al
call print_char
jmp .DisplayChar
.Done:
popad
ret
any idea what could be wrong?
Re:My print string function
I was reading throw some old posts and are wondering if i could get a more detailed explenation on the things that Candy points out below?
And this might be the solution to the print problem:
how do i fix this?Candy wrote: and your stack pointer & gdt are:so that is WAY over the limit. It ends up at a 81ae which is a LOT more than 0x17.Code: Select all
esp:0x9ffc3 gdtr:base=0x88e4, limit=0x17
PS: your stack pointer is unaligned. Align it .
And this might be the solution to the print problem:
but how do i fix this?Candy wrote: You don't set the org for your kernel properly!
The call to your string printing function disassembles as:Your string is at 0x00100005. You currently try to print the interrupt vector table.Code: Select all
(0).[572064] [0x00100230] 0008:00100230 (unk. ctxt): mov ESI, 00000015 ; be15000000 (0).[572064] [0x00100235] 0008:00100235 (unk. ctxt): mov AL, 0e ; b00e (0).[572064] [0x00100237] 0008:00100237 (unk. ctxt): call 001000cd ; e891feffff
Re:My print string function
I finally got it working, throw pm with Candy.
Thanks to all that have helped me.
A nice picture:
I will attach the final (and working) version of text.inc
Hmm, what to do next?
/ bubach
Thanks to all that have helped me.
A nice picture:
I will attach the final (and working) version of text.inc
Hmm, what to do next?
/ bubach