Skip to content

Commit

Permalink
Fix code generation with -obj-slack
Browse files Browse the repository at this point in the history
Reported by Miha Korenjak.
  • Loading branch information
Timotej Lazar committed Apr 14, 2024
1 parent 9be1d67 commit 37dd11e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/sic/asm/visitors/WriteText.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ private void flushBuf() {
if (recordBytes == 0) return;
String codeString = buf.toString();
while (recordBytes > 0) {
int length = codeString.length() <= 60 ? codeString.length() / 2 : 30;
w("T%s%06X%s%02X", space, textAddr, space, length);
w(codeString.substring(0, length * 2));
codeString = codeString.substring(length * 2);
int i = 0;
int nibbles = 0;
for (i = 0; i < codeString.length() && nibbles < 60; i++)
if (codeString.charAt(i) != ' ')
nibbles++;
int bytes = nibbles / 2;
w("T%s%06X%s%02X", space, textAddr, space, bytes);
w(codeString.substring(0, i));
codeString = codeString.substring(i);
w("\n");
textAddr += length;
recordBytes -= length;
textAddr += bytes;
recordBytes -= bytes;
}
buf = new StringBuilder();
recordBytes = 0;
Expand Down

0 comments on commit 37dd11e

Please sign in to comment.