Skip to content

bug in PUTSP trap implementation? #51

Open
@pro465

Description

@pro465

in

lc3-vm/docs/index.html

Lines 929 to 944 in e854c34

<pre class="prettyprint"><code class="">{
/* one char per byte (two bytes per word)
here we need to swap back to
big endian format */
uint16_t* c = memory + reg[R_R0];
while (*c)
{
char char1 = (*c) &amp; 0xFF;
putc(char1, stdout);
char char2 = (*c) &gt;&gt; 8;
if (char2) putc(char2, stdout);
++c;
}
fflush(stdout);
}
</code></pre>

it seems that the trap only stops printing when it encounters a 0x0000. however, the specification says that:

A character string consisting of an odd
number of characters to be written will have x00 in bits [15:8] of the memory
location containing the last character to be written.

in my interpretation, it sounds like the trap should stop when it has encountered a 0x0000, or it should print the first byte, and if the second byte is 0x00, it should stop, otherwise it should print it too. but this does not align with your implementation. i wonder whether it is a bug or my interpretation is wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions