Skip to content

Commit

Permalink
Fixed object padding to long boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed May 8, 2024
1 parent fd34df5 commit ea5a4a5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,15 @@ void testByte() throws Exception {

Assertions.assertEquals(""
+ "' Object header (var size 0)\n"
+ "00000 00000 0B 00 Object size\n"
+ "00000 00000 0C 00 Object size\n"
+ "00002 00002 01 Method count + 1\n"
+ "00003 00003 00 Object count\n"
+ "00004 00004 000 org $000\n"
+ "00004 00004 000 01 byte 1\n"
+ "00005 00005 000 02 byte 2\n"
+ "00006 00006 000 03 03 04 04 byte 3[2], 4[3]\n"
+ "0000A 0000A 001 04 byte 3[2], 4[3]\n"
+ "0000B 0000B 00 Padding\n"
+ "", compile(text));
}

Expand All @@ -301,7 +302,7 @@ void testWord() throws Exception {

Assertions.assertEquals(""
+ "' Object header (var size 0)\n"
+ "00000 00000 12 00 Object size\n"
+ "00000 00000 14 00 Object size\n"
+ "00002 00002 01 Method count + 1\n"
+ "00003 00003 00 Object count\n"
+ "00004 00004 000 org $000\n"
Expand All @@ -310,6 +311,7 @@ void testWord() throws Exception {
+ "00008 00008 001 03 00 03 00 word 3[2], 4[3]\n"
+ "0000C 0000C 002 04 00 04 00 \n"
+ "00010 00010 003 04 00\n"
+ "00012 00012 00 00 Padding\n"
+ "", compile(text));
}

Expand All @@ -326,7 +328,7 @@ void testBytefit() throws Exception {

Assertions.assertEquals(""
+ "' Object header (var size 0)\n"
+ "00000 00000 09 00 Object size\n"
+ "00000 00000 0C 00 Object size\n"
+ "00002 00002 01 Method count + 1\n"
+ "00003 00003 00 Object count\n"
+ "00004 00004 000 org $000\n"
Expand All @@ -335,6 +337,7 @@ void testBytefit() throws Exception {
+ "00006 00006 000 02 bytefit $02\n"
+ "00007 00007 000 80 bytefit -$80\n"
+ "00008 00008 001 FF bytefit $FF\n"
+ "00009 00009 00 00 00 Padding\n"
+ "", compile(text));

Assertions.assertThrows(CompilerException.class, new Executable() {
Expand Down Expand Up @@ -373,7 +376,7 @@ void testWordfit() throws Exception {

Assertions.assertEquals(""
+ "' Object header (var size 0)\n"
+ "00000 00000 0E 00 Object size\n"
+ "00000 00000 10 00 Object size\n"
+ "00002 00002 01 Method count + 1\n"
+ "00003 00003 00 Object count\n"
+ "00004 00004 000 org $000\n"
Expand All @@ -382,6 +385,7 @@ void testWordfit() throws Exception {
+ "00008 00008 001 02 00 wordfit $0002\n"
+ "0000A 0000A 001 00 80 wordfit -$8000\n"
+ "0000C 0000C 002 FF FF wordfit $FFFF\n"
+ "0000E 0000E 00 00 Padding\n"
+ "", compile(text));

Assertions.assertThrows(CompilerException.class, new Executable() {
Expand Down Expand Up @@ -468,7 +472,7 @@ void testValueSizeOverride() throws Exception {

Assertions.assertEquals(""
+ "' Object header (var size 0)\n"
+ "00000 00000 1E 00 Object size\n"
+ "00000 00000 20 00 Object size\n"
+ "00002 00002 01 Method count + 1\n"
+ "00003 00003 00 Object count\n"
+ "00004 00004 000 org $000\n"
Expand All @@ -481,6 +485,7 @@ void testValueSizeOverride() throws Exception {
+ "00016 00016 004 99 BB\n"
+ "00018 00018 005 AA FF 11 55 wordfit $FFAA, long $BB995511\n"
+ "0001C 0001C 006 99 BB\n"
+ "0001E 0001E 00 00 Padding\n"
+ "", compile(text));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void testByte() throws Exception {
+ "00001 00001 000 02 byte 2\n"
+ "00002 00002 000 03 03 04 04 byte 3[2], 4[3]\n"
+ "00006 00006 001 04 byte 3[2], 4[3]\n"
+ "00007 00007 00 Padding\n"
+ "", compile(text));
}

Expand All @@ -372,6 +373,7 @@ void testWord() throws Exception {
+ "00004 00004 001 03 00 03 00 word 3[2], 4[3]\n"
+ "00008 00008 002 04 00 04 00 \n"
+ "0000C 0000C 003 04 00\n"
+ "0000E 0000E 00 00 Padding\n"
+ "", compile(text));
}

Expand Down Expand Up @@ -416,6 +418,7 @@ void testBytefit() throws Exception {
+ "00002 00002 000 02 bytefit $02\n"
+ "00003 00003 000 80 bytefit -$80\n"
+ "00004 00004 001 FF bytefit $FF\n"
+ "00005 00005 00 00 00 Padding\n"
+ "", compile(text));

Assertions.assertThrows(CompilerException.class, new Executable() {
Expand Down Expand Up @@ -460,6 +463,7 @@ void testWordfit() throws Exception {
+ "00004 00004 001 02 00 wordfit $0002\n"
+ "00006 00006 001 00 80 wordfit -$8000\n"
+ "00008 00008 002 FF FF wordfit $FFFF\n"
+ "0000A 0000A 00 00 Padding\n"
+ "", compile(text));

Assertions.assertThrows(CompilerException.class, new Executable() {
Expand Down Expand Up @@ -847,6 +851,7 @@ void testValueSizeOverride() throws Exception {
+ "00012 00012 004 99 BB\n"
+ "00014 00014 005 AA FF 11 55 wordfit $FFAA, long $BB995511\n"
+ "00018 00018 006 99 BB\n"
+ "0001A 0001A 00 00 Padding\n"
+ "", compile(text));
}

Expand All @@ -873,6 +878,7 @@ void testAlignment() throws Exception {
+ "00009 00009 00009 11 1A 00 F6 mov a, b\n"
+ "0000D 0000D 0000D 01 00 00 00 a long 1\n"
+ "00011 00011 00011 01 00 00 00 b long 1\n"
+ "00015 00015 00 00 00 Padding\n"
+ "", compile(text));
}

Expand Down Expand Up @@ -919,6 +925,7 @@ void testFVarOverride() throws Exception {
+ "00000 00000 000 org $000\n"
+ "00000 00000 000 63 63 byte 99, fvar 99\n"
+ "00002 00002 000 9D 9D 7F byte -99, fvars -99\n"
+ "00005 00005 00 00 00 Padding\n"
+ "", compile(text));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void testLong() throws Exception {
void testByteSize() throws Exception {
Assertions.assertArrayEquals(new byte[] {
(byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03,
(byte) 0x03, (byte) 0x03,
(byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x00,
}, compile("DAT\n byte 1[2],3[4]\n"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,10 @@ else if (line.getMnemonic() != null && !(line.getInstructionFactory() instanceof
stringDataLine.writeTo(object);
}

object.alignToLong();
}

object.alignToLong();

objectSize.setValue(object.getSize());

return object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,10 @@ else if (address > fitAddress) {
if (index > 0) {
methodData.get(index).setValue(object.getSize());
}

object.alignToLong();
}

object.alignToLong();

return object;
}

Expand Down

0 comments on commit ea5a4a5

Please sign in to comment.