radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.67k stars 3k forks source link

radare2 does not assemble right opcodes for instructuction "ld a, 0x63" for gameboy #16994

Open gogo2464 opened 4 years ago

gogo2464 commented 4 years ago

This template is meant for bug reports, if you have a feature request, please be as descriptive as possible and delete the template

Make sure you are testing using the latest git version of radare2 before submitting any issue.

If you would like to report a bug, please fill the template below

Work environment

Questions Answers
OS/arch/bits (mandatory) ubuntu 19.10 x64
File format of the file you reverse (mandatory) gameboy save file with gameboy instructions
Architecture/bits of the file (mandatory) gameboy
r2 -v full output, not truncated (mandatory) radare2 4.5.0-git 24710 @ linux-x86-64 git.4.4.0-229-g5817770e2 commit: 5817770e290b3c66a3fe57850db6dda1c44c6a19 build: 2020-06-01__20:40:26

Expected behavior

wa ld a, 0x63 should write the opcodes 3e63

Actual behavior

wa ld a, 0x63 actually writes 3663

Steps to reproduce the behavior

I did r2 -w myfile; e cfg.bigendian=false; e asm.arch=gb then wa ld a, 0x63; then r2 still write 3663 that is read as ld [hl], 0x63 by radare2 disassembler;

Additional Logs, screenshots, source-code, configuration dump, ...

Drag and drop zip archives containing the Additional info here, don't use external services or link.

gogo2464 commented 4 years ago

@condret does this commit https://github.com/radareorg/radare2/commit/c5a2a6562e0cfcb662f8bb1b36726d911c4905bb close the current issue?

gogo2464 commented 4 years ago

@condret I made another test with:

:> wa ld [0xcfc7], a Cannot assemble 'ld [0xcfc7], a' at line 3

It also failed. I think I can put it here.

gogo2464 commented 4 years ago

@condret when I do wa ld hl, [0xc82e], the new value of hl is 0000. This may be related. Do I open a new issue?