Page 2 of 2
Re: Strange behaviour of compiler (Same code is not working
Posted: Sun Dec 25, 2016 2:24 am
by SpyderTL
That site is pretty impressive. If only there were an onlineassembler.com to go with it, I could do all of my OS development on my iPhone.
It does, however, make me realize just how primitive our development tools really are.
For example, the site will show you, graphically, which code runs in a loop, and which code blocks call other code blocks. When I get a chance, I'm going to try uploading my entire compiled OS to see what it looks like.
Re: Strange behaviour of compiler (Same code is not working
Posted: Sun Dec 25, 2016 5:57 am
by dozniak
SpyderTL wrote:That site is pretty impressive. If only there were an onlineassembler.com to go with it,
There's something for C++-to-assembler online, which is quite nice too
http://godbolt.org
Re: Strange behaviour of compiler (Same code is not working
Posted: Sun Dec 25, 2016 11:31 am
by Agola
Octocontrabass wrote:Agola wrote:That made me suspect about optimization for recursive functions
Is keyboard_getchar() supposed to be recursive? If so, you've forgotten a "return" statement.
Code: Select all
if (scancode & 0x80) return keyboard_getchar();
Is it possible the "keyboard_getchar()" was working without return?
Because it was working, I know. Just not sure it was "return keyboard_getchar();" or "keyboard_getchar();"
And does newlib handle backspace while reading from stdin?
Or have I handle backspace myself?
Re: Strange behaviour of compiler (Same code is not working
Posted: Sun Dec 25, 2016 12:44 pm
by Octocontrabass
Agola wrote:Is it possible the "keyboard_getchar()" was working without return?
Maybe, maybe not. I would have to see the code you lost to tell you.
Agola wrote:And does newlib handle backspace while reading from stdin?
Or have I handle backspace myself?
As far as I can tell, newlib doesn't handle backspace when reading from anything.
Re: Strange behaviour of compiler (Same code is not working
Posted: Sun Dec 25, 2016 1:41 pm
by Agola
Octocontrabass wrote:Agola wrote:Is it possible the "keyboard_getchar()" was working without return?
Maybe, maybe not. I would have to see the code you lost to tell you.
Agola wrote:And does newlib handle backspace while reading from stdin?
Or have I handle backspace myself?
As far as I can tell, newlib doesn't handle backspace when reading from anything.
I think the old "keyboard_getchar()" was:
Code: Select all
char keyboard_getchar()
{
while (!(inb(0x64) & 0x1));
unsigned char scancode = inb(0x60);
if (scancode & 0x80) keyboard_getchar();
char chr = key_list[scancode];
terminal_putchar(chr);
return chr;
}
Maybe I deleted the return *accidentally*, or maybe it was working and it is not working now (that is strange
)
Compared their assembly outputs, they look nearly identical, I don't know what is the problem really