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 #2 (bad type of some parameters for some z80/68k low-level commands) #86

Closed
wants to merge 2 commits into from

Conversation

adriweb
Copy link
Contributor

@adriweb adriweb commented Mar 12, 2024

And also add some safety flags to the cmake build...

@adriweb adriweb changed the title fix the type of some parameters for some z80/68k low-level commands fix #2 (bad type of some parameters for some z80/68k low-level commands) Mar 12, 2024
@@ -540,7 +540,10 @@ int ti82_send_asm_exec(CalcHandle* handle, VarEntry * var)
endptr = (var->name[0] == 0x24 ? fpBase : tempMem);
buffer[8] = 0x2a; buffer[9] = LSB(endptr); buffer[10] = MSB(endptr);
/* ld de, -program_size */
#pragma warning(push)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma isn't portable in the first place, but would #pragma msvc ... be possible at least for the warning(disable:4146) ?

Copy link
Contributor Author

@adriweb adriweb Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I know, but gcc and clang just warn that it's an unknown pragma and ignore it anyway :P

But contrary to those two compilers with a compiler-name-as-first-arg, it looks like #pragma msvc isn't a thing...
So I suppose we could add #ifdef _MSC_VER/#endif for each. but that's whole lot of extra lines just to disable a warning, bleh.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a step back... fixing the code would be better :)
offset should be int32_t, and after adding an early bounds check against < 2 and >= 32768 (both models have 32 KB of physical RAM) on var->size below VALIDATE_VARENTRY(var), something like offset = -(int32_t)((uint16_t)var->size - 2); should do the job, hopefully without the compilers complaining about numerical value truncation or overflows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's probably better. We'll have to compare the actual output in buffer just in case...

@adriweb
Copy link
Contributor Author

adriweb commented Mar 16, 2024

I'll close this PR since e5ad813 was integrated.
But we still need to do something about the ASM generation part...

@adriweb adriweb closed this Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants