Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix INT8 that was unsigned instead of signed #13

Merged
merged 1 commit into from Mar 14, 2019

Conversation

Projects
None yet
3 participants
@flozz
Copy link
Contributor

flozz commented Feb 25, 2019

Since 2016, the char type is unsigned by default in SDCC. From the SDCC ChageLog:

2016-02-01 Philipp Klaus Krause <pkk AT spth.de>

	* src/SDCCglobl.h,
	  src/SDCCmain.c,
	  src/SDCCsymt.c,
	  src/SDCCval.c,
	  doc/sdccman.lyx:
	  Make char unsigned by default.

As the INT8 type is based on char, this make it unsigned...

This PR fixes the issue. There is also an other possible fix: using the --fsigned-char option of the compiler.

Here a small code that reproduce the issue:

#include <stdio.h>
#include <gb/gb.h>

void main(void) {
    INT8 x = 10;
    INT8 dx = -1;
    printf("INT8 x = 10;\n");
    printf("INT8 dx = -1;\n\n");
    printf("x + dx = %i\n", x + dx);
}

Result before the fix:

capture d ecran de 2019-02-25 14-01-19

And after the patch:

capture d ecran de 2019-02-25 14-01-34

@andreasjhkarlsson

This comment has been minimized.

Copy link
Owner

andreasjhkarlsson commented Mar 14, 2019

Nice find! Thanks a lot!

@andreasjhkarlsson andreasjhkarlsson merged commit e7353c4 into andreasjhkarlsson:master Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.