static void do_write(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia) { void *scratch_buffer = NULL; int d = (int)cpu_registers(processor)->gpr[arg0]; unsigned_word buf = cpu_registers(processor)->gpr[arg0+1]; int nbytes = cpu_registers(processor)->gpr[arg0+2]; int status; SYS(write); if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%lx, %d", d, (long)buf, nbytes); /* get a tempoary bufer */ scratch_buffer = zalloc(nbytes); /* FIXME - nbytes == 0 */ /* copy in */ emul_read_buffer(scratch_buffer, buf, nbytes, processor, cia); /* write */ status = write(d, scratch_buffer, nbytes); emul_write_status(processor, status, errno); free(scratch_buffer); flush_stdoutput(); }
static void emul_bugapi_do_write(os_emul_data *bugapi, cpu *processor, unsigned_word cia, unsigned_word buf, int nbytes, const char *suffix) { void *scratch_buffer = NULL; /* get a tempoary bufer */ if (nbytes > 0) { scratch_buffer = zalloc(nbytes); /* copy in */ emul_read_buffer(scratch_buffer, buf, nbytes, processor, cia); /* write */ device_instance_write(bugapi->output, scratch_buffer, nbytes); zfree(scratch_buffer); } if (suffix) device_instance_write(bugapi->output, suffix, strlen(suffix)); flush_stdoutput (); }