Why it's not possible give args to functions
Why it's not possible give args to functions
I'm in the way to become crazy, in the attempt to understand why the values I give to the functions args are simply ignored
Thanks to everyone will reply
Thanks to everyone will reply
- Attachments
-
- smile.zip
- (12.02 KiB) Downloaded 170 times
Re: Why it's not possible give args to functions
In which file would this be taking place? Just post some of the relevant code here and leave the rest attached.
Visit the Montrom user page for more info.
Re: Why it's not possible give args to functions
char* vga=(char*)0xb8000;
uint32 counter=0;
void putc(const char c){
vga[counter]=(char)c;
vga[counter+1]=66;
counter+=2;
};
and when i call putc from main no value to the function has been given...
uint32 counter=0;
void putc(const char c){
vga[counter]=(char)c;
vga[counter+1]=66;
counter+=2;
};
and when i call putc from main no value to the function has been given...
Re: Why it's not possible give args to functions
How do you know this ? Do you know for sure that main is reached ? I suspect that it is not. start.asm looks incomplete.and when i call putc from main no value to the function has been given...
- gerryg400
If a trainstation is where trains stop, what is a workstation ?
Re: Why it's not possible give args to functions
Sure, main is called by the start routine in start.asm. The problem is the value I assign to the arg. I don't know the reason. If I change the putc function with somethink like
void putc(const char c){
vga[counter]='g'; //Any other direct value
vga[counter+1]=66;
counter+=2;
};
It works....
void putc(const char c){
vga[counter]='g'; //Any other direct value
vga[counter+1]=66;
counter+=2;
};
It works....
- 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: Why it's not possible give args to functions
Have you checked what ESP is pointing to?
Re: Why it's not possible give args to functions
The values are transferred via the stack, there is no such thing as "no value" on the stack. Your function will (try to) access the stack no matter what. As Combuster implied, you probably have a stack problem.Karlosoft wrote:and when i call putc from main no value to the function has been given...
JAL
Re: Why it's not possible give args to functions
The value is always set 0...
mov esp, _sys_stack ; This points the stack to our new stack area
Is the third line of start.asm, the only place where I directly change the address of esp
mov esp, _sys_stack ; This points the stack to our new stack area
Is the third line of start.asm, the only place where I directly change the address of esp
Re: Why it's not possible give args to functions
Dunno if it matters but you are calling the kn function before the dtors stuff. You should be calling kn from near the jmp $
If a trainstation is where trains stop, what is a workstation ?
- 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: Why it's not possible give args to functions
Ok, you must be kidding me.
Your kernel, in the BIOS area?link.ld wrote:phys = 0xFF800000;
Re: Why it's not possible give args to functions
I just used the address where bootf jumps to
It use a little strange gtd where the first mb is defined with that address... I think -.-
mov CR3, eax ;Set up page directory
mov eax, CR0 ;Turn on paging and protected mode
or eax, 0x80000001
mov CR0, eax
mov cl, flat_data ;Setup ds and es
push cx ;{5}
pop ds
mov es, cx
jmp dword 8:0xFF800000 ;Go
A piece of code of bootf
It use a little strange gtd where the first mb is defined with that address... I think -.-
mov CR3, eax ;Set up page directory
mov eax, CR0 ;Turn on paging and protected mode
or eax, 0x80000001
mov CR0, eax
mov cl, flat_data ;Setup ds and es
push cx ;{5}
pop ds
mov es, cx
jmp dword 8:0xFF800000 ;Go
A piece of code of bootf
Re: Why it's not possible give args to functions
The bug seem to be just in the data space, because the code works fine. It's possible that the problem is linked to the paging enabled by bootloader?
Re: Why it's not possible give args to functions
MOV AX, 0x10 ; 0x10 points at the new data selector
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
I had to add these few lines in start.asm ^_^ now it runs good
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
I had to add these few lines in start.asm ^_^ now it runs good