Z80Disasm { public static List<Z80Instruction> decodeList(final MemoryAccessProvider memoryAccessProvider, final List<Z80Instruction> container, final int offset, final int instructionsToDecode) { final List<Z80Instruction> result = container == null ? new ArrayList<Z80Instruction>() : container; int off = offset; int instructionsCounter = instructionsToDecode; while (instructionsCounter > 0) { final Z80Instruction i = decodeInstruction(memoryAccessProvider, off); result.add(i); if (i == null) { off++; } else { off += i.getLength(); } instructionsCounter--; } return result; } private  Z80Disasm(); static List<Z80Instruction> decodeList(final MemoryAccessProvider memoryAccessProvider,
                                                final List<Z80Instruction> container,
                                                final int offset, final int instructionsToDecode); static Z80Instruction decodeInstruction(final MemoryAccessProvider memoryAccessProvider,
                                                 final int offset);  }
@Test public void testDecodeList() { final ByteArrayMemoryAccessProvider memoryProvider = new ByteArrayMemoryAccessProvider(new byte[] { (byte) 0xBB, (byte) 0x6D, (byte) 0xEF, (byte) 0x40, (byte) 0x45, (byte) 0x21, (byte) 0x00, (byte) 0x00, (byte) 0x22, (byte) 0x4B, (byte) 0x84, (byte) 0x21, (byte) 0xA8, (byte) 0x9D, (byte) 0xEF, (byte) 0x0A, (byte) 0x45, (byte) 0xEF, (byte) 0x2E, (byte) 0x45, (byte) 0xC9, (byte) 0x48, (byte) 0x65, (byte) 0x6C, (byte) 0x6C, (byte) 0x6F, (byte) 0x20, (byte) 0x77, (byte) 0x6F, (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x21, (byte) 0x00}); final List<Z80Instruction> list = Z80Disasm.decodeList(memoryProvider, null, 0, 26); assertEquals(26, list.size()); assertNotNull(list.get(24)); final StringBuilder builder = new StringBuilder(); int off = 0; for (final Z80Instruction i : list) { if (i == null) { builder.append("<UNKNOWN>\n"); off++; } else { builder.append(i.decode(memoryProvider, off, off + 0x4000)).append('\n'); off += i.getLength(); } } assertEquals("CP E\n" + "LD L,L\n" + "RST #28\n" + "LD B,B\n" + "LD B,L\n" + "LD HL,#0000\n" + "LD (#844B),HL\n" + "LD HL,#9DA8\n" + "RST #28\n" + "LD A,(BC)\n" + "LD B,L\n" + "RST #28\n" + "LD L,#45\n" + "RET\n" + "LD C,B\n" + "LD H,L\n" + "LD L,H\n" + "LD L,H\n" + "LD L,A\n" + "JR NZ,#4093\n" + "LD L,A\n" + "LD (HL),D\n" + "LD L,H\n" + "LD H,H\n" + "LD HL,#BB00\n" + "LD L,L\n" , builder.toString()); }