Strange letter displays before string [ACTUALLY SOLVED]

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.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Strange letter displays before string [ACTUALLY SOLVED]

Post by DixiumOS »

I made my own simple print string routine, hosted on https://github.com/NunoLava1998/DixiumOS-1 (First commit)

However, when i try to run this in QEMU, a phantom monochrome S appears before my text:
Image

How would i fix this unexpected character?
Last edited by DixiumOS on Wed Jan 11, 2017 4:52 am, edited 2 times in total.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Strange letter displays before string

Post by bzt »

DixiumOS wrote:How would i fix this unexpected character?
Debug your code and find the instruction that puts it there. Then modify your source to avoid that.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Strange letter displays before string

Post by Octacone »

I don't like the way your code works. You should have two separate functions: one for printing characters and one for printing characters at a certain position. Your clear screen functions is really really bad, the most unoptimized function ever. Tomorrow I am going to make a GitHub account and edit your repository a bit and help you with your OS + commentary included. Try printing that string without calling your clear screen function.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

octacone wrote:I don't like the way your code works. You should have two separate functions: one for printing characters and one for printing characters at a certain position. Your clear screen functions is really really bad, the most unoptimized function ever. Tomorrow I am going to make a GitHub account and edit your repository a bit and help you with your OS + commentary included. Try printing that string without calling your clear screen function.
writechar is different than writestring:

Write char writes a character at the specified foreground, background, x position, y position.
Write string uses write char to write a string using the same technique as used in the Bare Bones tutorial. Both can print characters at a certain position, but one writes strings and another writes characters.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Strange letter displays before string

Post by iansjack »

You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.

All the same, an improvement on your previous efforts.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.

All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.

EDIT: It doesn't clear. Must be a problem in my putchar.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
hannah
Member
Member
Posts: 34
Joined: Wed Oct 12, 2016 11:32 am
Location: At my PC

Re: Strange letter displays before string

Post by hannah »

DixiumOS wrote:
iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.

All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.

EDIT: It doesn't clear. Must be a problem in my putchar.
Push my pull request
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Strange letter displays before string

Post by iansjack »

bzt wrote: Debug your code and find the instruction that puts it there. Then modify your source to avoid that.
None of the OP's code puts the character there. More to the point - look at the code and see why it doesn't write to that location.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

hannah wrote:
DixiumOS wrote:
iansjack wrote:You never write to the top left of the screen (row 0, column 0), so what appears there ("S") is what was left over from the BIOS.

All the same, an improvement on your previous efforts.
Thank you.
I also moved the string to 40, 10 and it displayed fine but that S was still there.
I'll make a terminal_init that clears the screen and that S.

EDIT: It doesn't clear. Must be a problem in my putchar.
Push my pull request
Pushed it. I think i'm unpushing it (code is wrong, various things are undefined and many things are defined for no reason and then never used, and the types in 2 functions don't even exist.)
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Strange letter displays before string

Post by Octocontrabass »

Hmm.

Any particular reason you created a new account, NunoLava1998?
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

Octocontrabass wrote:Hmm.

Any particular reason you created a new account, NunoLava1998?
I want to start over again.

And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).

Got it working, thanks everybody!

https://github.com/NunoLava1998/DixiumO ... inal/tty.c
Last edited by DixiumOS on Wed Jan 11, 2017 2:44 am, edited 1 time in total.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Strange letter displays before string

Post by Octocontrabass »

DixiumOS wrote:And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).
You didn't fix it, you just added a second bug that hides the first bug.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

Octocontrabass wrote:
DixiumOS wrote:And good news, i got it working (i had to change (y * 80 + x) to (y * 80 + x - 1)).
You didn't fix it, you just added a second bug that hides the first bug.
So... what bug?

It works perfectly fine on QEMU and seems logical:

Image
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Strange letter displays before string

Post by Octocontrabass »

User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: Strange letter displays before string

Post by DixiumOS »

Octocontrabass wrote:This bug.
That isn't a bug. If i didn't add that line, only the last char would display in the specified x and y like i used putchar.

Besides, here's another image demonstrating it works:

Image
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Post Reply