comparison 68kinst.c @ 2213:53411df7fc71

More 68K disassembler refactoring and fix Windows build failure
author Michael Pavone <pavone@retrodev.com>
date Mon, 29 Aug 2022 21:58:37 -0700
parents 8554751f17b5
children d8b0244101c4
comparison
equal deleted inserted replaced
2212:71b0cb7c34a6 2213:53411df7fc71
2 Copyright 2013 Michael Pavone 2 Copyright 2013 Michael Pavone
3 This file is part of BlastEm. 3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. 4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5 */ 5 */
6 #include "68kinst.h" 6 #include "68kinst.h"
7 #include "disasm.h"
7 #include <string.h> 8 #include <string.h>
8 #include <stdio.h> 9 #include <stdio.h>
9 10
10 uint32_t sign_extend16(uint32_t val) 11 uint32_t sign_extend16(uint32_t val)
11 { 12 {
2588 } else { 2589 } else {
2589 return m68k_disasm_op(decoded, dst, need_comma, labels, address, label_fun, data); 2590 return m68k_disasm_op(decoded, dst, need_comma, labels, address, label_fun, data);
2590 } 2591 }
2591 } 2592 }
2592 2593
2593 int m68k_default_label_fun(char * dst, uint32_t address, void * data) 2594 int m68k_disasm_ex(m68kinst * decoded, char * dst, uint8_t labels, format_label_fun label_fun, disasm_context *data)
2594 {
2595 return sprintf(dst, "ADR_%X", address);
2596 }
2597
2598 int m68k_disasm_ex(m68kinst * decoded, char * dst, uint8_t labels, format_label_fun label_fun, void * data)
2599 { 2595 {
2600 int ret,op1len; 2596 int ret,op1len;
2601 uint8_t size; 2597 uint8_t size;
2602 char * special_op = "CCR"; 2598 char * special_op = "CCR";
2603 switch (decoded->op) 2599 switch (decoded->op)
2705 int m68k_disasm(m68kinst * decoded, char * dst) 2701 int m68k_disasm(m68kinst * decoded, char * dst)
2706 { 2702 {
2707 return m68k_disasm_ex(decoded, dst, 0, NULL, NULL); 2703 return m68k_disasm_ex(decoded, dst, 0, NULL, NULL);
2708 } 2704 }
2709 2705
2710 int m68k_disasm_labels(m68kinst * decoded, char * dst, format_label_fun label_fun, void * data) 2706 int m68k_disasm_labels(m68kinst * decoded, char * dst, disasm_context *disasm)
2711 { 2707 {
2712 if (!label_fun) 2708 return m68k_disasm_ex(decoded, dst, 1, format_label, disasm);
2713 {
2714 label_fun = m68k_default_label_fun;
2715 }
2716 return m68k_disasm_ex(decoded, dst, 1, label_fun, data);
2717 } 2709 }