39 lines
1.2 KiB
C
Raw Normal View History

2024-09-09 01:30:45 +06:00
#pragma once
2024-09-10 21:13:01 +06:00
#include "ppc-inst.h"
2024-09-09 01:30:45 +06:00
2024-09-09 08:13:57 +06:00
/* A macro to extract the major opcode from an instruction. */
#define PPC_OP(i) (((i) >> 26) & 0x3f)
/* A macro to extract the extended opcode from an instruction. */
#define PPC_XOP(i) (((i) >> 1) & 0x3ff)
2024-09-11 08:58:50 +06:00
/* A macro to extract the branch destination from a conditional instruction. */
#define PPC_BD(i) ((signed int)((((i) & 0xFFFC) ^ 0x8000) - 0x8000))
/* A macro to extract the branch destination from an immediate instruction. */
#define PPC_BI(i) ((signed int)((((i) & 0x3FFFFFC) ^ 0x2000000) - 0x2000000))
/* A macro to extract whether the branch is absolute. */
#define PPC_BA(i) (!!((i) & 2))
/* A macro to extract whether the branch is a link. */
#define PPC_BL(i) (!!((i) & 1))
2024-09-11 22:06:01 +06:00
/* A macro to extract the branch operation of an instruction. */
#define PPC_BO(i) (((i) >> 21) & 0x1F)
2024-09-09 08:13:57 +06:00
#define PPC_OP_TDI 2
#define PPC_OP_TWI 3
#define PPC_OP_MULLI 7
#define PPC_OP_SUBFIC 8
#define PPC_OP_CMPLI 0xA
#define PPC_OP_CMPI 0xB
#define PPC_OP_ADDIC 0xC // addic
#define PPC_OP_ADDICR 0xD // addic.
#define PPC_OP_ADDI 0xE
#define PPC_OP_ADDIS 0xF
#define PPC_OP_BC 0x10
#define PPC_OP_SC 0x11
#define PPC_OP_B 0x12
#define PPC_OP_CTR 0x13