| 1 |
/* |
| 2 |
* Copyright 2025 Valve Corporation |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
#include <stdio.h> |
| 6 |
#include <stdlib.h> |
| 7 |
#include "util/bitset.h" |
| 8 |
|
| 9 |
signed agx2_disassemble_instr(BITSET_WORD *code, FILE *fp, unsigned offset, |
| 10 |
bool verbose); |
| 11 |
|
| 12 |
static inline bool |
| 13 |
agx2_disassemble(uint8_t *code, size_t max_len, FILE *fp) |
| 14 |
{ |
| 15 |
int i = 0; |
| 16 |
bool errors = false; |
| 17 |
|
| 18 |
while (i < max_len) { |
| 19 |
/* Break on trap */ |
| 20 |
if (code[i + 0] == 0x08 && code[i + 1] == 0x00) |
| 21 |
break; |
| 22 |
|
| 23 |
signed ret = |
| 24 |
agx2_disassemble_instr((BITSET_WORD *)(code + i), fp, i, true); |
| 25 |
if (ret < 0) |
| 26 |
fprintf(fp, "XXX error here\n"); |
| 27 |
|
| 28 |
errors |= ret < 0; |
| 29 |
i += abs(ret); |
| 30 |
} |
| 31 |
|
| 32 |
return errors; |
| 33 |
} |