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

Invalid executable in the fab-agon-emulator #4

Closed
gianlucarenzi opened this issue Dec 18, 2023 · 7 comments
Closed

Invalid executable in the fab-agon-emulator #4

gianlucarenzi opened this issue Dec 18, 2023 · 7 comments

Comments

@gianlucarenzi
Copy link

Following the directions in the Readme.md to install the toolchain everything seems to be ok.
When compiling some code (args demo) it gives me (with the fab-agon-Emulator 0.9.11) Invalid executable.
I am using it in the following procedure:
1- Start the Emulator with: fab-agon-emulator --firmware quark (I am using the Official Quark VDP emulator as well) 2- Type *BYE to exit from BBC Basic 3- load args.bin 4-run &040000 Hello World Invalid executable

The code is compiling simply invoking the command: make
[compiling] src/args.c [lto opt] obj/lto.bc [convimg] description [linking] bin/args.bin [success] bin/args.8xp, 8462 bytes.

The same problem is with the bin or 8xp file.

Can you help me out?
Regards,
Gianluca

@kristofer
Copy link

kristofer commented Jan 3, 2024

not sure, but the TI stuff (ti/screen.h and ti/getcsc.h) are not Agon interfaces. I have the same problem with args/argv, I only get 1 in argc, the name of the executable; anything I append to either the load or run commands do not get passed as strings into the argv array.

I suspect this is just WIP "not working yet" and will continue to look for clues.

@kristofer
Copy link

And this just now... for a main.c

int main(int argc, char **argv) {
	printf("TCVM\n\r");
	    for (int i = 0; i < argc; i++)
    {
	printf("%d %s\n\r", argc, argv[i]);
    }

	if (argc < 2) fail("usage: tcvm program [args]");
	Args = argv;
	Narg = argc;
	printf ("TCVM Starting...\r\n");
	// load(argv[1]);
	// run();
	return EXIT_SUCCESS;
}

and this was the result

image

notice how the tokens hello world on the load line were ignored, and on the run line the second token was picked up at argv[1]...

@kristofer
Copy link

kristofer commented Jan 3, 2024

And then this...
image

BUT the .bin that was loaded before, is the one memory resident for the run command. a run does not load a new binary even if you put it as the first arg of the run command.
Thursday morning: And now, after having read the read me a lot more closely, I think I get what's going on WRT argc argv and will stop commenting here.

@astralaster
Copy link
Collaborator

notice how the tokens hello world on the load line were ignored, and on the run line the second token was picked up at argv[1]...
In the documentation of run its stated that the first argument is the address where the program is loaded. So its expected to skip this argument in your program.

@kristofer
Copy link

yes, And if you put something nonsense there like xxx is seems to affect nothing. I'm also looking at why sometimes, you have to do a load to make a command in mos/ run. If it changes on the sdcard, there seems to be some situations when running the command by name doesn't clear the old version out of memory first.
I am generating executable with the AgDev c compiler, and copying them into the emulator's sdcard directory. Doing series of test runs, it seems this weird not loading the new version of the executable is happening.
Could it be related to the file timestamps (which seem to be bogus) (although, the idea that MOS checks timestamps to see if they have changed before loading (or re-loading) the executable again - well, doesn't seem likely. I need to look at the MOS code)

@astralaster
Copy link
Collaborator

If you use LOAD it reads the file and copies it to the memory. If you use RUN it executes the program in the memory. So you can then even delete the file and still RUN it.

@astralaster
Copy link
Collaborator

I'm pretty sure binaries created with this toolchain do work in the emulator (because I use it all the time). So it must be some installation error.

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

No branches or pull requests

3 participants