Page 1 of 1

OSDK C and the scanf() function

Posted: Sat Jul 21, 2018 12:22 pm
by astrofra

I'm quickly testing C programming in OSDK 1.11 and want to use the scanf() function.
Has anyone tried it before ?

I'm testing the following :

Code: Select all

// Using the Scanf() ANSI-C function

#include <stdio.h>

void main()
	char my_str[256];
	printf("What is your name ?\n");
	scanf("%s", my_str);
	printf("Hello %s!\n", my_str);
However, at the moment I get the following answer from the linker :
Building the program HWSIMPLE at adress $800
Compiling MAIN.C
- preprocess
- compile
- convert C to assembly code
- cleanup output
ldx #262
D:\apps\dev\osdk\sample\c\scanf\MAIN.s(3): 08bd:Overflow error
scanbuf reserve 256
D:\apps\dev\osdk\sample\c\scanf\scanf.s(8): 090d:Syntax error
fieldcount db 0
D:\apps\dev\osdk\sample\c\scanf\sscanf.s(53): 0973:Syntax error
numberscan dw 0
D:\apps\dev\osdk\sample\c\scanf\sscanf.s(166): 0a42:Syntax error
signscan db 0
D:\apps\dev\osdk\sample\c\scanf\sscanf.s(167): 0a42:Label defined error
Break after 5 errors
ERROR : Build failed.
Press any key to continue . . .
Dear Oric fellows, any idea of what I'm doing wrong? (attached is my C tiny program)

Re: OSDK C and the scanf() function

Posted: Sat Jul 21, 2018 12:31 pm
by Dbug

As it happens, you are probably the first person having tried to use scanf in the OSDK since we switched to XA instead of FRAsm.

Basically we forgot to convert the syntax for the scanf.s and sscanf.s files in the lib folder.
I just fixed that, but until I release a new version of the OSDK you need to use a temporary fix:
- reserve -> .dsb
- db -> .byt
- dw -> .word
I attached the working files in the zip file.

Also, your overflow error is not something that can be fixed, you have added a 256 bytes local variable in your main, that's not going to work very well.
If you move the "char my_str[256];" out of main() that should work just fine.