/// <summary> /// Write the subroutine which takes a compressed venture card table as input and writes it into ventureCardDecompressedTableAddr /// </summary> /// <param name="ventureCardDecompressedTableAddr">The address for the reserved memory space to store the decompressed venture card table in</param> private List <UInt32> writeSubroutine(VAVAddr ventureCardDecompressedTableAddr) { var asm = new List <UInt32>(); PowerPcAsm.Pair16Bit ventureCardTableAddrPair = PowerPcAsm.make16bitValuePair((UInt32)ventureCardDecompressedTableAddr); /// /// assume: /// r6 = ventureCardCompressedTableAddr /// /// variables: /// r4 = ventureCardId /// r5 = ventureCardCompressedTableAddr /// r6 = ventureCardDecompressedTableAddr /// r7 = ventureCardCompressedWord /// r8 = bitIndex /// r0 = tmp / currentByte /// /// return: /// r6 = ventureCardDecompressedTableAddr /// asm.Add(PowerPcAsm.li(4, 0)); // ventureCardId = 0 asm.Add(PowerPcAsm.mr(5, 6)); // r6 is ventureCardCompressedTableAddr at this point. Copy it to r5 with which we will be working asm.Add(PowerPcAsm.lis(6, ventureCardTableAddrPair.upper16Bit)); // \ load the ventureCardDecompressedTableAddr into r6. This address is asm.Add(PowerPcAsm.addi(6, 6, ventureCardTableAddrPair.lower16Bit)); // / where we will store the decompressed venture card table. int whileVentureCardIdSmaller128 = asm.Count; // do { { // asm.Add(PowerPcAsm.li(0, 0)); // \ load the next compressed word from ventureCardCompressedTableAddr asm.Add(PowerPcAsm.lwzx(7, 5, 0)); // / into r7. We will decompress the venture card table word by word. asm.Add(PowerPcAsm.li(8, 31)); // bitIndex = 31 int whileBitIndexGreaterEqual32 = asm.Count; // do { // { asm.Add(PowerPcAsm.mr(0, 7)); // get the current compressed word asm.Add(PowerPcAsm.srw(0, 0, 8)); // shift it bitIndex times to the right asm.Add(PowerPcAsm.andi(0, 0, 1)); // retrieve the lowest bit of it -> r0 contains the decompressed venture card byte now. asm.Add(PowerPcAsm.stbx(0, 4, 6)); // store it into ventureCardDecompressedTableAddr[ventureCardId] asm.Add(PowerPcAsm.subi(8, 8, 1)); // bitIndex-- asm.Add(PowerPcAsm.addi(4, 4, 1)); // ventureCardId++ asm.Add(PowerPcAsm.cmpwi(8, 0)); // asm.Add(PowerPcAsm.bge(asm.Count, whileBitIndexGreaterEqual32)); // } while(bitIndex >= 0) } // asm.Add(PowerPcAsm.addi(5, 5, 4)); // ventureCardCompressedTableAddr += 4 asm.Add(PowerPcAsm.cmpwi(4, 128)); // asm.Add(PowerPcAsm.blt(asm.Count, whileVentureCardIdSmaller128)); // } while(ventureCardId < 128) } // asm.Add(PowerPcAsm.li(4, 0)); // \ reset r4 = 0 asm.Add(PowerPcAsm.li(5, 0)); // / reset r5 = 0 asm.Add(PowerPcAsm.blr()); // return return(asm); }