justinmeiners/lc3-vm

Missing fflush?

auzkok opened this issue · 1 comments

Hi,
shouldn't there be fflush(stdout) in this block?

case TRAP_IN:
                        /* TRAP IN */
                        {
                            printf("Enter a character: ");
                            char c = getchar();
                            putc(c, stdout);
                            reg[R_R0] = (uint16_t)c;
                        }

                        break;

Nice catch! An fflush is needed after the putc. Without it, the character won't be echoed until the next time stdout is flushed.

While trying to create a sample program to reproduce the issue, I actually ran into another issue with the input traps. It turns out they aren't updating the condition flags when they should be, so I created #44 for that.

I've opened a PR that should fix both of these issues (#45).