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

PUSH/POP shift ss too much #10

Open
neldredge opened this issue Mar 9, 2023 · 0 comments
Open

PUSH/POP shift ss too much #10

neldredge opened this issue Mar 9, 2023 · 0 comments

Comments

@neldredge
Copy link

In the push/pop instructions, the value of ss is multiplied by 0x10 before passing to Address::calculate_from_offset:

let ss = vm.arch.ss as usize*0x10;
let sp = vm.arch.sp as usize;
let base = Address::calculate_from_offset(ss,sp);

But the latter multiplies by 0x10 again:

make_valid_address(base.into() * 0x10 + offset.into())

So ss effectively gets shifted 8 bits instead of 4.

You can reproduce with

mov ax, 0x1000
mov ss, ax
mov sp, 0x20
mov bx, 0xdead
push bx

and note that address 0x0001e gets written instead of 0x1001e as it should.

@neldredge neldredge changed the title push/pop handle ss incorrectly push/pop shift ss too much Mar 9, 2023
@neldredge neldredge changed the title push/pop shift ss too much PUSH/POP shift ss too much Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant