Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6502] Indirect Addressing incorrect #196

Open
thestr4ng3r opened this issue Nov 12, 2019 · 1 comment
Open

[6502] Indirect Addressing incorrect #196

thestr4ng3r opened this issue Nov 12, 2019 · 1 comment

Comments

@thestr4ng3r
Copy link
Contributor

Example:

[0x00000000]> wx a142b1428113913760
[0x00000000]> af
[0x00000000]> pdf
┌ 9: fcn.0 (int8_t arg_100h, int8_t arg_101h);
│           0x00000000      a142           lda (0x42,x)
│           0x00000002      b142           lda (0x42),y
│           0x00000004      8113           sta (0x13,x)
│           0x00000006      9137           sta (0x37),y
└           0x00000008      60             rts

Expected:

/* r2dec pseudo code output */
/* malloc://512 @ 0x0 */
#include <stdint.h>
 
void fcn_0 () {
    acc = *(*(0x42 + x));
    acc = *((*0x42) + y);
    *(*(0x13 + x)) = acc;
    *((*0x37) + y) = acc;
    return;
}

Actual:

/* r2dec pseudo code output */
/* malloc://512 @ 0x0 */
#include <stdint.h>
 
void fcn_0 () {
    do {
label_0:
        acc = *(0x42);
        acc += x;
    } while (1);
    acc = *((0x42 + y));
    goto label_0;
    *(0x13) = acc;
    acc += x;
    goto label_0;
    *((0x37 + y)) = acc;
    goto label_0;
    return;
    goto label_0;
}

The gotos and the do/while seem wrong too.

pddi: 6502_pddi.json.gz

@wargio
Copy link
Owner

wargio commented Nov 13, 2019

it's r2 giving me those jumps. the bug must be in r2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants