wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
400 stars 44 forks source link

fix(rp2040): change RSBS and SBCS according to CMP/SUBS implementation #59

Closed Turro75 closed 3 years ago

Turro75 commented 3 years ago

SBCS reworked to reflect latest SUBS implementation RSBS (NEGS) is actually a special case of SUBS where leftValue is 0

close #58

urish commented 3 years ago

This got me thinking - since all these functions share the same logic, perhaps it'll be better if way make a function (e.g. subtractUpdateFlags or something like that) that:

  1. Takes leftValue and rightValue as arguments
  2. Calculates the result
  3. Updates the flag
  4. Returns the result

Then, instructions like SUBS will use the result (e.g. store it in a register), while CMP will call this function just to update the flags, without using the result.

What do you think?

Turro75 commented 3 years ago

that's good, I'll do it Tomorrow before the stream

urish commented 3 years ago

Excellent, thanks!

Turro75 commented 3 years ago

I moved also addition instructions to a dedicated function, created a new PR