Printing new line on boot

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.
MichaelPetch
Member
Member
Posts: 712
Joined: Fri Aug 26, 2016 1:41 pm
Freenode IRC: mpetch

Re: Printing new line on boot

Post by MichaelPetch »

Since you are using USB per your answer, is it using USB Floppy emulation in the BIOS? If so - many BIOSes will clobber bytes in memory after loading your bootloader into memory since it may blindly assume you have a BIOS Parameter block at the beginning of your bootloader. If your BIOS is booting with USB floppy emulation - then do you have a BIOS Parameter block in your code? The overwriting of your code after being loaded can possibly lead to your code not working as expected.
Octocontrabass
Member
Member
Posts: 5218
Joined: Mon Mar 25, 2013 7:01 pm

Re: Printing new line on boot

Post by Octocontrabass »

I still think using a BIOS function that relies on the value in BX without first setting BX is at least part of the problem.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Printing new line on boot

Post by onlyonemac »

mondelob wrote:
onlyonemac wrote:Try pushing everything to the stack before calling the BIOS function and then popping it afterwards. If this works then I'm guessing that the BIOS function is corrupting a register that you aren't expecting it to. Check the documentation for the function that you're using and see what registers are supposed to be preserved, if you're expecting it to preserve registers that it isn't supposed to preserve then it's possible that it might work on some BIOSes that happen to preserve those registers but not on others that don't, otherwise your BIOS is evidently corrupting a register that it's supposed to preserve.

Im a bit new in ASM, you push every register before calling the function, and then once I entered in for example printc or newline; pop all the registers?
Yes.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Printing new line on boot

Post by onlyonemac »

Octocontrabass wrote:I still think using a BIOS function that relies on the value in BX without first setting BX is at least part of the problem.
That's not going to cause this issue. Whatever (uninitialised) value is in BX is obviously fine for printing other characters and won't cause newlines specifically to fail. So yes this is a problem but it's not relevant here.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Octocontrabass
Member
Member
Posts: 5218
Joined: Mon Mar 25, 2013 7:01 pm

Re: Printing new line on boot

Post by Octocontrabass »

Printing characters to the screen is separate from the special case handling for carriage return and line feed. There's no reason to assume the code for these two separate functions will behave the same way with an out-of-range value in BX.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Printing new line on boot

Post by onlyonemac »

Octocontrabass wrote:Printing characters to the screen is separate from the special case handling for carriage return and line feed. There's no reason to assume the code for these two separate functions will behave the same way with an out-of-range value in BX.
BX does only two things: control the colour of the characters displayed, and control which text page the characters appear on. BX presumably contains a value that causes characters to appear in a visible colour and on the currently-visible page. If the values were "out of range", the characters would either be in an invisible colour or off the screen.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Post Reply