MMIXware Version
mmix-20131017
Bug Reported
Initial: 20/03/2023
Author
Junchang Liu
Description
If data between BSPEC and ESPEC is not TETRA aligned it will not be written
to the output file.
For example:
LOC #100
BSPEC 5
BYTE #FE
TETRA #FFFF
ESPEC
Main ADD $1,$1,$1
will not write the given special data to the output file but instead
marks the ADD instruction as special as can be seen with mmotype:
98090101
6419c6e6
File was created Sat Feb 12 09:27:10 1887
. . .
98080005
Special data 5 at loc 0000000000000100 ("spec.mms", line 3)
20010101
20010101
980a00ff
. . .
Proposed Patch
The bug is in the function assemble(k,dat,x_bits)
where we have (shortened):
if (spec_mode) l=spec_mode_loc;
. . .
for (j=0;j<k;j++) {
jj=(l+j)&3;
hold_buf[jj]=(dat>>(8*(k-1-j)))&0xff;
held_bits|=1<<jj;
. . .
}
. . .
if (((l+k)&3)==0) {
. . .
mmo_clear();
}
if (spec_mode) spec_mode_loc+=k;
Calling assemble with k=1 and then with k=4 will never call mmo_clear()
and nothing will be written to the output file. mmo_clear will only be
called if (once in a while) the total sum over all k is 0 mod 4.
I propose to integrating the test into the for-loop as follows:
if (spec_mode) l=spec_mode_loc;
. . .
for (j=0;j<k;j++) {
jj=(l+j)&3;
hold_buf[jj]=(dat>>(8*(k-1-j)))&0xff;
held_bits|=1<<jj;
. . .
. . .
if (((l+j+1)&3)==0) {
. . .
mmo_clear();
}
}
if (spec_mode) spec_mode_loc+=k;
Discussion
This bug was fixed.
|