private void alignAndPackBitField(InternalDataTypeComponent dataTypeComponent) {

		BitFieldDataType bitfieldDt = (BitFieldDataType) dataTypeComponent.getDataType();

		if (lastComponent != null && lastComponent.isZeroBitFieldComponent()) {
			int alignment = bitFieldPacking.useMSConvention() ? getBitFieldAlignment(bitfieldDt)
					: zeroAlignment;
			adjustZeroLengthBitField(nextOrdinal - 1, alignment);
		}

		int offset;
		int bitsConsumed;

		// update lastAlignment to be conveyed onto structure alignment
		int alignment = CompositeAlignmentHelper.getPackedAlignment(
			bitfieldDt.getPrimitiveBaseDataType().getAlignment(), packValue);

		// Set conveyed alignment early since bitfield alignment may be reduced below
		lastAlignment = Math.max(alignment, lastAlignment);

		if (lastComponent == null) {
			offset = DataOrganizationImpl.getAlignedOffset(alignment, groupOffset);
			bitsConsumed = 0;
			groupOffset = offset; // establish corrected group offset after alignment
		}
		else if (lastComponent.isZeroBitFieldComponent()) {
			// - assume lastComponent (zero-length bitfield) has already been adjusted and updated
			// - first bitfield following a :0 bitfield which has already been adjusted by packComponent
			// - groupOffset contains aligned offset to be used
			offset = groupOffset;
			bitsConsumed = 0;
		}
		else {

			// follow normal rule for aligning bitfield which may differ from the alignment
			// imparted onto structure via lastAlignment
			alignment = getBitFieldAlignment(bitfieldDt);

			BitFieldDataType lastBitfieldDt = null;
			if (lastComponent.isBitFieldComponent()) {

				// assume lastComponent bit-field has already been packed and has correct bit-offset

				lastBitfieldDt = (BitFieldDataType) lastComponent.getDataType();
				offset = lastComponent.getEndOffset();
				if (dataOrganization.isBigEndian()) {
					// filled left-to-right
					bitsConsumed = 8 - lastBitfieldDt.getBitOffset();
					// bitsConsumed range: 1 to 8, where 8 indicates last byte fully consumed
				}
				else { // little-endian
						// filled right-to-left (viewed from normalized form after byte-swap)
					bitsConsumed =
						(lastBitfieldDt.getBitSize() + lastBitfieldDt.getBitOffset()) % 8;
					// bitsConsumed range: 0 to 7, where 0 indicates last byte fully consumed
				}
				if (bitsConsumed == 8 || bitsConsumed == 0) {
					// last byte is fully consumed
					bitsConsumed = 0;
					++offset;
				}

			}
			else {
				// previous field is non-bitfield
				offset = lastComponent.getOffset() + lastComponent.getLength();
				bitsConsumed = 0;
			}

			int byteSize = (bitfieldDt.getBitSize() + bitsConsumed + 7) / 8;
			int endOffset = offset + byteSize - 1;

			if (offset % alignment != 0 || byteSize > bitfieldDt.getBaseTypeSize()) {
				// offset is not an aligned offset (which may be OK when packing with lastComponent)
				int alignedBaseOffset =
					DataOrganizationImpl.getAlignedOffset(alignment, offset) - alignment;
				if (endOffset >= alignedBaseOffset + bitfieldDt.getBaseTypeSize()) {
					// skip ahead to next aligned offset
					offset = DataOrganizationImpl.getAlignedOffset(alignment, offset + 1);
					endOffset = offset + byteSize - 1;
					bitsConsumed = 0;
				}
			}

			// establish new groupOffset if necessary
			if (groupOffset >= 0 && lastBitfieldDt != null &&
				endOffset >= (groupOffset + lastBitfieldDt.getBaseTypeSize())) {
				groupOffset = bitFieldPacking.useMSConvention() ? offset : -1;
			}
		}

		int byteSize = setBitFieldDataType(dataTypeComponent, bitfieldDt, bitsConsumed);

		updateComponent(dataTypeComponent, nextOrdinal, offset, byteSize, alignment);
	}
Adjust lastComponent which must be a zero-length bitfield and its associated
groupOffset based upon the adjusted alignment.
@param ordinal component ordinal assignment
@param minimumAlignment minimum alignment of component immediately after
the zero-length component
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedComponentPacker.java