Commit Graph

13 Commits

Author SHA1 Message Date
Stephen Heumann 3c1f357b0c Save a few bytes in the startup code. 2023-03-28 21:38:55 -05:00
Stephen Heumann a4ba2403fe Call atexit functions with correct data bank in large memory model
Previously, the functions registered with atexit() would be called with data bank corresponding to the blank segment, which is correct in the small memory model but not necessarily in the large memory model. This could cause memory corruption or misbehavior for certain operations accessing global variables.
2023-03-28 18:52:14 -05:00
Stephen Heumann 74de206058 Add library function for null pointer checking.
This is used by the new ORCA/C debugging option to check for illegal use of null pointers. It is similar to an existing routine in PasLib used by ORCA/Pascal's similar checks.
2023-02-12 18:57:56 -06:00
Stephen Heumann 69765a96ef Use a variable to control use of Time Tool.
This ensures use of the Time Tool is fully under the control of the programmer, rather than potentially being affected by other things that may load it (like the Time Zone CDev). It also avoids calls to tiStatus in the default non-Time Tool code paths, and thereby allows them to work under Golden Gate.
2023-01-02 18:01:28 -06:00
Stephen Heumann 73ed0778f2 Add cleanup code for CDev calls.
The new CDev root code generated by ORCA/C will now branch to this code after each CDev call, giving it an opportunity to clean up if necessary. Specifically, it will dispose of the user ID allocated for the CDev if it is going away after this call. There are several cases where this occurs, which need to be detected based on the message code passed to the CDev and in some cases other factors.
2022-12-12 18:01:28 -06:00
Stephen Heumann 7b6cb049b7 Add an 16-bit unsigned multiply routine suitable for use in C.
This differs from the existing ~UMul2 in SysLib in that it gives the low-order 16 bits of the true result in the event of overflow. The C standards require this behavior for computations on unsigned types.
2022-07-06 22:19:32 -05:00
Stephen Heumann 379f2f93ad Fix bug causing data corruption when assigning to multiple structs.
This affects code where multiple structs or unions are assigned by successive = operators in one expression, e.g. "s1=s2=s3". The middle struct assignment(s) would use the ~Move2 or ~LongMove2 helper functions (for <64k or >=64k moves, respectively). These functions are supposed to leave the destination pointer on the stack so it can be used as the source of a subsequent move, but they both had bugs where they could modify dest and leave that modified value on the stack, which would cause subsequent moves to use the wrong source location. In the case of ~Move2, this only happened if the size was odd.

Here is a program that demonstrated the problems with both functions:

#pragma memorymodel 1
#include <stdio.h>

struct S1 {
        char s[80000];
} a,b,c;

int main(void) {
        struct S2 {
                int x,y;
                char z;
        } d,e,f;

        c.s[66000] = 123;
        f.y = 5678;

        a = b = c;
        d = e = f;

        printf("%i %i %i\n", a.s[66000], b.s[66000], c.s[66000]);
        printf("%i %i %i\n", d.y, e.y, f.y);
}
2021-09-17 18:25:32 -05:00
Stephen Heumann 573bc6efa9 Use consistent indentation within files.
Tabs have been expanded to spaces in several files that use mainly spaces for indentation.

The files ctype.asm, stdio.asm, and string.asm consistently use tabs for indentation. The tabs in these files have been left alone, except that a few tabs between sentences in comments were changed to spaces.  One space-indented line in stdio.asm was changed to use a tab.
2020-02-16 13:28:18 -06:00
Stephen Heumann ee1b7e606d Implement quick_exit() and at_quick_exit() from C11.
Also, make all the exit functions quit via RTL if #pragma rtl was used. This fixes #19.
2020-01-23 18:43:20 -06:00
Stephen Heumann 8533ea221c When argc==0, argv should be a valid pointer and argv[0] should be NULL.
This is normal for S16 programs or inits, and can happen with shell executables in certain cases like when being run from Prizm.
2018-02-28 00:17:35 -06:00
Kelvin Sherlock d95f9f29d2 during initial count of arguments on the command-line, use the same logic as the second count when the argv vector is built. 2018-02-24 22:40:01 -05:00
Kelvin Sherlock 578bda8439 CR -> LF 2017-10-31 13:14:07 -04:00
mikew50 954c3a02b5 ORCA libraries, from the Opus ][ CD 2017-10-01 18:00:58 -06:00