Skip to content

Instantly share code, notes, and snippets.

@ghostrider-reborn
Last active October 24, 2023 05:50
Show Gist options
  • Save ghostrider-reborn/bfd3e9c6ea468b92ca0251c7462757b5 to your computer and use it in GitHub Desktop.
Save ghostrider-reborn/bfd3e9c6ea468b92ca0251c7462757b5 to your computer and use it in GitHub Desktop.
Extract major and minor value from QTI perf opcode
#include <stdio.h>
#define EXTRACT_MAJOR_TYPE 0x1FC00000
#define EXTRACT_MINOR_TYPE 0x000FC000
#define SHIFT_BIT_MAJOR_TYPE 22
#define SHIFT_BIT_MINOR_TYPE 14
int main()
{
unsigned int opcode;
unsigned char major, minor;
printf("Enter opcode in hex: ");
scanf("%x", &opcode);
major = (opcode & EXTRACT_MAJOR_TYPE) >> SHIFT_BIT_MAJOR_TYPE;
minor = (opcode & EXTRACT_MINOR_TYPE) >> SHIFT_BIT_MINOR_TYPE;
printf("major=0x%X minor=0x%X", major, minor);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment