Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Conversation

@LoipesMas
Copy link

Hello,
I've made a guessing game in porth.
It's compile only, because it uses read syscall to read stdin and uses argv pointer to get pseudo random number.
I might try to implement the read syscall in simulation later.
Not sure if I should mark this as draft.

mem 10 + 1 .64

//read stdin
255 mem 20 + stdout SYS_read syscall3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you reading from stdout? you should read from stdin and write to stdout right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. Didn't notice it, because it works anyway lol.
Will fix that

Copy link
Contributor

@drocha87 drocha87 Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, this works because you're not redirecting the stdout/stderr/stdin. Try something like this ./examples/guessing_game 2>&1 | tee -a some_file and you program will segfault.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I also wrote stdin in place of stdout in some other places :|
All fixed now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants