AdoHTQ / Batpu2-VM

MIT License
28 stars 10 forks source link

Bug with subtracting #35

Closed Ianyourgod closed 1 week ago

Ianyourgod commented 1 week ago

Hello. I ran this code:

ldi r1 230 ldi r2 1 sub r2 r1 r3

(1-230) this should result in 229, but i got 27. I'm guessing this has to do with the vm trying to make this not negative, but failing (-27 is the same as 229 in 8 bits)

Noname-Official commented 1 week ago

You're doing 1 - 230, not 230 - 1

Ianyourgod commented 1 week ago

You're doing 1 - 230, not 230 - 1

yes, but it should still be the same result... right?

Ianyourgod commented 1 week ago

yeah just checked, 1-230 with 8 bits should still be 229 wait i did it wrong one sec gonna try again

erinsc commented 1 week ago

1-230 = -229 == 27 mod 256

Ianyourgod commented 1 week ago

damn i did it wrong, thanks yall