Printing new line on boot
-
- Member
- Posts: 799
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Printing new line on boot
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.
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Printing new line on boot
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.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Printing new line on boot
Yes.mondelob wrote: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?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.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Printing new line on boot
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.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.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Printing new line on boot
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.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Printing new line on boot
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.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.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing