weird m68hc11 emulos sim code

Mike Frysinger vapier@gentoo.org
Sat Jan 30 15:40:08 GMT 2021


it looks like this came in via the initial port back in 2000.  i'm not
familiar with this target or emulos, so hopefully you can explain it
as you were the author :).

sim/m68hc11/emulos.c:

// This is called by M6811_EMUL_SYSCALL.
void
emul_os (int code, sim_cpu *cpu)
{
  cpu->cpu_current_cycle = 8;
  switch (code)
    {
      /* 0xCD 0x01 */
    case 0x01:
      emul_write (cpu);
      break;
...

static void 
emul_write (sim_cpu *cpu)
{
  int addr = cpu_get_x (cpu) & 0x0FFFF;
  int size = cpu_get_d (cpu) & 0x0FFFF;

  if (addr + size > 0x0FFFF) {
    size = 0x0FFFF - addr;
  }
  cpu->cpu_running = 0;
  while (size)
    {
      uint8 val = memory_read8 (cpu, addr);

      write(0, &val, 1);
      addr ++;
      size--;
    }
}

it's writing to fd 0 which is stdin.  is that correct ?
was this meant to write to stdout as a sort of debug syscall ?
-mike


More information about the Gdb mailing list