Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
557B

  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include "../emul.h"
  4. /* runbin loads binary from stdin directly in memory address 0 then runs it
  5. * until it halts. The return code is the value of the register A at halt time.
  6. */
  7. int main()
  8. {
  9. Machine *m = emul_init();
  10. // read stdin in mem
  11. int i = 0;
  12. int c = getchar();
  13. while (c != EOF) {
  14. m->mem[i] = c & 0xff;
  15. i++;
  16. c = getchar();
  17. }
  18. if (!i) {
  19. fprintf(stderr, "No input, aborting\n");
  20. return 1;
  21. }
  22. emul_loop();
  23. return m->cpu.R1.br.A;
  24. }