Strange behaviour of compiler (Same code is not working now)

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.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Strange behaviour of compiler (Same code is not working

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Strange behaviour of compiler (Same code is not working

Post 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
Learn to read.
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: Strange behaviour of compiler (Same code is not working

Post 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?
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Strange behaviour of compiler (Same code is not working

Post 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.
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: Strange behaviour of compiler (Same code is not working

Post 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 :shock:
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
Post Reply