MEGA65 / mega65-core

MEGA65 FPGA core
Other
240 stars 85 forks source link

Add PHQ/PLQ opcodes #536

Closed lydon42 closed 1 month ago

lydon42 commented 2 years ago

BitShifter asked if it is possible to implement 32bit push and pop operations to the Q opcode set. It is used in the ROM and might have some benefit there.

lydon42 commented 2 years ago

@gardners and I think that it is not a big benefit to implement those:

I think I thought about PHQ and PLQ, and decided it would be a lot of work for not much gain. The four PHx / PLx instructions only cost one cycle each plus the stack bus access = 8 cycles IIRC. Having a single one with prefix would be at least 6 cycles. Not saying that we can't do them, just that the cost/benefit ratio is maybe not so great at the moment.

The whole push/pop mechanic lies within the microcode and is quite complicated to extend.

lgblgblgb commented 2 years ago

The are other situations like that, when having a "Q-opcode" has minimal gain but creates much more complexity (thus may not worth it ...), like having LDQ #... (but surely my example is even more worse since it hurts the principle Paul told once, that the length of the opcode should not be altered by prefix, and in this case it would, ie a 32 bit constant after # instead of only a 8 bit one). But in theory it's an interesting idea to have LDQ #... with a 8 bit constant only, that is, the rest of the "Q" is filled with zeroes, since it's often a case we need a Q-op soon, but the constant would fit into 8 bits quantity (but for this, maybe an opcode for "sign extension" from A to Q or anything like that would be more useful?)

lydon42 commented 1 month ago

Closed in favor of #645