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

RUN and JMP should push and pop registers #55

Open
rprouse opened this issue Apr 25, 2023 · 2 comments
Open

RUN and JMP should push and pop registers #55

rprouse opened this issue Apr 25, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@rprouse
Copy link

rprouse commented Apr 25, 2023

Currently assembly programs need to push all the registers before calling main then pop the registers before the program returns. Most other operating systems do this for you, so it is confusing for new developers. C programs also need to include assembly to do the same before calling into main.

Writing code like this in every program seems a waste. It would be much easier if MOS did it before and after running the program.

_start:
	push af
	push bc
	push de
	push ix
	push iy

	call _main

	pop iy
	pop ix
	pop de
	pop bc
	pop af

	ld hl, 0
	ret

Added bonus, also parse the arguments and put them in a defined location in memory? 😄

@rprouse
Copy link
Author

rprouse commented Apr 25, 2023

I've tested stripping out the push and pop instructions and the program still runs although I didn't test running as a command. Are they needed?

If I remove the ld hl,0, then garbage is printed before the command prompt returns.

@breakintoprogram
Copy link
Owner

HL is used as the MOS return error code. 0 = OK. There is no bounds checking on that table. I will look into that as part of this fix.

I'd argue that JMP doesn't need to push registers as it is not intended to return neatly to MOS, but will look into it for RUN.

@breakintoprogram breakintoprogram added the enhancement New feature or request label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: On Hold
Development

No branches or pull requests

2 participants