gbdev / gb-opcodes

https://gbdev.io/gb-opcodes/optables/
Creative Commons Zero v1.0 Universal
24 stars 10 forks source link

Fix "SRA" flags #6

Closed weibell closed 4 years ago

weibell commented 4 years ago

According to multiple sources, instructions CB28 ("SRA B") up to CB2F ("SRA A") use the carry flag to store the value of bit 8 prior to the right shift.

DaKnig commented 4 years ago

I don't have access to the hardware right now but it does work in both BGB and SameBoy.

JL2210 commented 4 years ago

The flag changes themselves are correct, but your description of them isn't. The original bit 0 is stored in the carry flag and bit 7 is left unchanged. (there's no bit 8 in an 8-bit number, as well)

avivace commented 4 years ago

@weibell Thanks for the contribution! Do you think you can work on some fixes for the descriptions?

weibell commented 4 years ago

@JL2210 You are right, I mixed up the description and yours is correct: Shift right into carry, storing the original bit 0 into the carry flag and leaving bit 7 unchanged.

@avivace Thank you. However, since #8 (containing exactly the same made in this pull request) has already been merged, I think we can close this pull request.

avivace commented 4 years ago

Great, thanks anyway, @weibell !