INIT_PIC stops text output!
INIT_PIC stops text output!
So,
I have been working on my hobby OS for a while now and it has been only in the last couple of weeks that I actually got everything working.
OK, I am using NASM and GCC on Vista and testing it using a Virtual Floppy Drive and VirtualBox.
So here is where I am in the code:
I got everything working and I am outputting to the screen directly using 0xb8000.
I have been working on getting keyboard input.
So, when I create my Keyboard driver in my kernel, it calls the method INIT_PICS from http://osdever.net/tutorials.php?cat=5&sort=1.
I have implemented all of the assembly routines already.
So here is the issue:
Whenever I test the OS, if I call INIT_PICS then none of my screen output works! There is no error, but the program just hangs.
Is there an issue with PIC and using 0xb8000?
Is there an issue with PIC in VirtualBox?
Do you have any ideas?
I have been working on my hobby OS for a while now and it has been only in the last couple of weeks that I actually got everything working.
OK, I am using NASM and GCC on Vista and testing it using a Virtual Floppy Drive and VirtualBox.
So here is where I am in the code:
I got everything working and I am outputting to the screen directly using 0xb8000.
I have been working on getting keyboard input.
So, when I create my Keyboard driver in my kernel, it calls the method INIT_PICS from http://osdever.net/tutorials.php?cat=5&sort=1.
I have implemented all of the assembly routines already.
So here is the issue:
Whenever I test the OS, if I call INIT_PICS then none of my screen output works! There is no error, but the program just hangs.
Is there an issue with PIC and using 0xb8000?
Is there an issue with PIC in VirtualBox?
Do you have any ideas?
Re: INIT_PIC stops text output!
Do you enable interrupts during your init routine? if so, you may be hanging in an ISR.
I'd use the BOCHS debugger to see where you're idling.
I'd use the BOCHS debugger to see where you're idling.
Website: https://joscor.com
Re: INIT_PIC stops text output!
Thanks!
Sorry,
This was really stupid of me... Somewhere my OutPort functions don't work.
I wrote them not with inline code, and I must have made a mistake changing it from AT&T to Intel...
So I just have a simpler question, what would the following inline function be if separated (assume NASM)?
Inline C
C:
Why doesn't this work?
ASM:
I must be forgetting to move the argument into dx. I'm not so good at assembly.
Could
work?
Sorry,
This was really stupid of me... Somewhere my OutPort functions don't work.
I wrote them not with inline code, and I must have made a mistake changing it from AT&T to Intel...
So I just have a simpler question, what would the following inline function be if separated (assume NASM)?
Inline C
Code: Select all
inline static void outportb(int port, unsigned char data)
{
asm volatile
(
"outb %%al, %%dx\n\t"
:
: "a" (data), "d" (port)
);
}
Code: Select all
extern "C" void writeOutB(int port, unsigned char data);
ASM:
Code: Select all
segment .text
_writeOutC:
out dx, al
Could
Code: Select all
segment .text
_writeOutC:
pop al
pop dx
out dx, al
Last edited by AltexPape on Sat May 16, 2009 5:40 pm, edited 1 time in total.
Re: INIT_PIC stops text output!
That, and you're not loading al, and you're not returning from it, you're just going off and executing some stuff. (Or is this called with some kind of regparm magic?)Why doesn't this work?
ASM:I must be forgetting to move the argument into dx. I'm not so good at assembly.Code: Select all
segment .text _writeOutC: out dx, al
Known working outportb-equivalent function:
Code: Select all
void write8(uint16 port, uint8 data)
{
asm volatile
(
"outb %0, %1"
::"a" (data), "Nd" (port)
);
}
Re: INIT_PIC stops text output!
Well,
I think I am making an assembly mistake.
So where would the two arguments be stored? I need to move something to AL, but where from?
I think I am making an assembly mistake.
So where would the two arguments be stored? I need to move something to AL, but where from?
Re: INIT_PIC stops text output!
Are you referring to the inline assembly version or the NASM version? The "a" and "d" in the inline assembly input list automatically put the values in al and dx. Those are substituted in by the compiler for %0 and %1.
Re: INIT_PIC stops text output!
I am referring to the NASM version. I already have separate code and I understand Intel better than AT&T syntax.scgtrp wrote:Are you referring to the inline assembly version or the NASM version? The "a" and "d" in the inline assembly input list automatically put the values in al and dx. Those are substituted in by the compiler for %0 and %1.
What is the code that I should have in my .ASM file?
Can I
Code: Select all
pop al
pop dx
out al, dx
Last edited by AltexPape on Sat May 16, 2009 5:58 pm, edited 1 time in total.
Re: INIT_PIC stops text output!
Try this:
Untested, but written based on what GCC generated given my function at -O1.
Code: Select all
outportb:
mov word dx, [esp+0x08]
mov byte al, [esp+0x04]
out dx, al
ret
Re: INIT_PIC stops text output!
Thanks all,
That worked, but since I suck at this, I am also trying to make the inport thing as well.
Same concept as the last question, what would the NASM code for inport?
This doesn't work:
Any ideas?
That worked, but since I suck at this, I am also trying to make the inport thing as well.
Same concept as the last question, what would the NASM code for inport?
Code: Select all
extern "C" char readInC(int port);
Code: Select all
_readInC:
mov word dx, [esp+0x08]
in al, dx
ret
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: INIT_PIC stops text output!
What is ESP pointing to?
What is your calling convention?
Where are your arguments?
Right now you seem to be programming blind.
What is your calling convention?
Where are your arguments?
Right now you seem to be programming blind.
-
- Member
- Posts: 199
- Joined: Sat Jun 28, 2008 6:44 pm
Re: INIT_PIC stops text output!
Altex, I'd suggest you go back and understand how assembly works.