當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mips-inst.parse函數代碼示例

本文整理匯總了TypeScript中mips-inst.parse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parse函數的具體用法?TypeScript parse怎麽用?TypeScript parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parse函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: compileWRITE16

 compileWRITE16(code: ICode) {
   return parse(`
     LUI ${this.REG1} ${this.getAddrUpper(code.addr)}
     ORI ${this.REG1} ${this.REG1} ${this.getAddrLower(code.addr)}
     ADDIU ${this.REG2} R0 ${code.value}
     SH ${this.REG2} 0(${this.REG1})
   `);
 }
開發者ID:PartyPlanner64,項目名稱:PartyPlanner64,代碼行數:8,代碼來源:compiler.ts

示例2: compileIFNOT16

 compileIFNOT16(code: ICode) {
   return parse(`
     LUI ${this.REG1} ${this.getAddrUpper(code.addr)}
     ORI ${this.REG1} ${this.REG1} ${this.getAddrLower(code.addr)}
     LH ${this.REG1} 0(${this.REG1})
     ADDIU ${this.REG2} R0 ${code.value}
     BEQ ${this.REG1} ${this.REG2} 4
   `);
 }
開發者ID:PartyPlanner64,項目名稱:PartyPlanner64,代碼行數:9,代碼來源:compiler.ts

示例3: findCalls

export function findCalls(dataView: DataView, jalAddr: number) {
  const jalInst = parse(`JAL ${jalAddr}`);
  const calls = [];
  for (let i = 0; i < dataView.byteLength; i += 4) {
    const inst = dataView.getUint32(i);
    if (inst === jalInst) {
      calls.push(i);
    }
  }
  return calls;
}
開發者ID:PartyPlanner64,項目名稱:PartyPlanner64,代碼行數:11,代碼來源:MIPS.ts

示例4: writeHookCode

  writeHookCode(romView: DataView) {
    const adapter = getROMAdapter();
    const MAINFS_READ_ADDR = adapter && adapter.MAINFS_READ_ADDR;
    if (!MAINFS_READ_ADDR) {
      throw new Error("Cheats were being applied, but the ROM adapter had no MAINFS_READ_ADDR");
    }

    // The first 4 bytes will be reserved to store the pointer to the cheat routine,
    // so we can remember where it is for subsequent frames.
    // The hook will immediately follow.
    let offset = this.HOOK_ROM_START_OFFSET + 4;

    // T9 = saved off V0 value
    // S7 = saved off RA value
    // A1 = address of cheat routine (either due to reading from cached location, or from the heap call)
    // A2 = "ver!" constant that is initially in RAM

    // Read the cached cheat routine address
    const cachedReadLocs = getRegSetUpperAndLower(this.HOOK_RAM_START_OFFSET);
    romView.setUint32(offset, parse(`LUI A1 ${0x8000 | cachedReadLocs[0]}`)); // A1 = 0x800C
    romView.setUint32(offset += 4, parse(`ADDIU A1 A1 ${cachedReadLocs[1]}`)); // A1 = 0x800CA900
    romView.setUint32(offset += 4, parse("LW A1 0(A1)"));

    // Check if the cached cheat routine address is legit. If not, this is the first execution and we need to get it
    romView.setUint32(offset += 4, parse(`LUI A2 ${this.HOOK_CACHE_DEFAULT_VALUE >>> 16}`)); // A2 = 0x76650000 "ve"
    romView.setUint32(offset += 4, parse(`ADDIU A2 A2 ${this.HOOK_CACHE_DEFAULT_VALUE & 0xFFFF}`)); // A2 = 0x76657221 "ver!"
    romView.setUint32(offset += 4, parse(`BNE A1 A2 11`)); // Jump to the JR A1

    // Prep to call mainfs read
    // Should save off V0 and RA, because they are needed to leave the controller routine properly.
    romView.setUint32(offset += 4, parse("ADDU T9 V0 R0")); // T9 <= V0
    romView.setUint32(offset += 4, parse("ADDU S7 RA R0")); // S7 <= RA

    // Read from MainFS if we don't have cheat buffer (only happens once)
    romView.setUint32(offset += 4, parse(`LUI A0 ${this.MAINFS_CHEAT_FILE[0]}`)); // A0 <= [The dir index]xxxx
    romView.setUint32(offset += 4, parse(`JAL ${MAINFS_READ_ADDR}`));
    romView.setUint32(offset += 4, parse(`ADDIU A0 A0 ${this.MAINFS_CHEAT_FILE[1]}`)); // A0 = [dir index][file index]

    // Cache off the cheat location
    romView.setUint32(offset += 4, parse(`LUI A1 ${0x8000 | cachedReadLocs[0]}`)); // A1 = 0x800C
    romView.setUint32(offset += 4, parse(`ADDIU A1 A1 ${cachedReadLocs[1]}`)); // A1 = 0x800CA900
    romView.setUint32(offset += 4, parse("SW V0 0(A1)"));
    romView.setUint32(offset += 4, parse("ADDU A1 V0 R0")); // A1 <= V0

    // Post-JAL cleanup, restore cached regs
    romView.setUint32(offset += 4, parse("ADDU V0 T9 R0")); // V0 <= T9
    romView.setUint32(offset += 4, parse("ADDU RA S7 R0")); // RA <= S7

    // A1 has the location of the cheat routine... jump to it!
    romView.setUint32(offset += 4, parse("JR A1"));
    romView.setUint32(offset += 4, 0); // NOP
  }
開發者ID:PartyPlanner64,項目名稱:PartyPlanner64,代碼行數:52,代碼來源:HookBase.ts


注:本文中的mips-inst.parse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。