mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-28 16:30:59 +00:00
91d33b586d
The main changes made to most tests are: *Declarations always include explicit types, not relying on implicit int. The declaration of main in most test programs is changed to be "int main (void) {...}", adding an explicit return type and a prototype. (There are still some non-prototyped functions, though.) *Functions are always declared before use, either by including a header or by providing a declaration for the specific function. The latter approach is usually used for printf, to avoid requiring ORCA/C to process stdio.h when compiling every test case (which might make test runs noticeably slower). *Make all return statements in non-void functions (e.g. main) return a value. *Avoid some instances of undefined behavior and type errors in printf and scanf calls. Several miscellaneous bugs are also fixed. There are still a couple test cases that intentionally rely on the C89 behavior, to ensure it still works.
73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
/* Special Conformance Test 25.0.2: Verification of long addressing in mini- */
|
|
/* assembler when using large memory model */
|
|
/* */
|
|
/* Other files needed: spc25.2.exec - EXEC file which separately compiles, */
|
|
/* links, and executes the two files */
|
|
/* comprising this test */
|
|
/* spc25.2.1.cc - Separately compiled file which */
|
|
/* contains global data and routines */
|
|
/* accessed by the main program */
|
|
|
|
#pragma memorymodel 1
|
|
#include <stdio.h>
|
|
|
|
static int i1 = 33;
|
|
|
|
extern char ch0 [];
|
|
extern int i0 [];
|
|
|
|
extern char * Init_Ch (void);
|
|
extern int * Init_Int (int i []);
|
|
|
|
|
|
int main (void)
|
|
{
|
|
char *chPtr;
|
|
int *iPtr;
|
|
int count = 0;
|
|
|
|
/* Call routines to initialize global arrays. Verify initialization. */
|
|
|
|
count++;
|
|
chPtr = Init_Ch ();
|
|
if ((*chPtr != 'e') || (chPtr [1] != 'd') || (chPtr [2] != 'c'))
|
|
goto Fail;
|
|
|
|
count++;
|
|
iPtr = Init_Int (i0);
|
|
if ((*iPtr != 10) || (iPtr [1] != 20) || (iPtr [2] != 30))
|
|
goto Fail;
|
|
|
|
asm
|
|
{
|
|
bra Test
|
|
|
|
uch1: dcb 't'
|
|
|
|
/* Test expressions */
|
|
|
|
Test: lda i1
|
|
cmp #33
|
|
bne Err
|
|
|
|
lda uch1
|
|
and #0x00FF
|
|
cmp #0x0074
|
|
bne Err
|
|
|
|
lda [iPtr]
|
|
cmp #10
|
|
beq Out
|
|
Err: inc count
|
|
jmp Fail
|
|
}
|
|
|
|
Out:
|
|
printf ("Passed Conformance Test 25.0.2\n");
|
|
return 0;
|
|
|
|
Fail:
|
|
printf ("count = %d\n", count);
|
|
printf ("Failed Conformance Test 25.0.2\n");
|
|
}
|