public List<IntelHexRecord> finish(Address entryPoint) {

		// Before finalizing things, write out any remaining bytes that haven't yet been written, if
		// the user has specified to do so via the drop extra bytes option (false = 
    	// write out everything).
		if (bytes.size() > 0 && !dropExtraBytes) {
			emitData();
		}

        if (entryPoint != null && isSegmented != null) {
            final long offset = entryPoint.getOffset();
            byte[] data = new byte[4];
            data[2] = (byte) ((offset >> 8) & 0xff);
            data[3] = (byte) (offset & 0xff);
            if (isSegmented) {
                SegmentedAddress saddress = (SegmentedAddress) entryPoint;
                int segment = saddress.getSegment();
                data[0] = (byte) ((segment >> 8) & 0xff);
                data[1] = (byte) (segment & 0xff);
                results.add(new IntelHexRecord(4, 0, 3, data));
            } else {
                data[0] = (byte) ((offset >> 24) & 0xff);
                data[1] = (byte) ((offset >> 16) & 0xff);
                results.add(new IntelHexRecord(4, 0, 5, data));
            }
        }
        results.add(new IntelHexRecord(0, 0, 1, new byte[0]));
        done = true;
        return Collections.unmodifiableList(results);
    }
Constructor

@param maxBytesPerLine the maximum number of bytes to write per line in the hex output
@param dropExtraBytes if true, only lines matching {@link #maxBytesPerLine} will be output; 
remaining bytes will be left out
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/IntelHexRecordWriter.java