Mirror of CollapseOS
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

28 Zeilen
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. }