0
\$\begingroup\$

I'm thinking about making a SUBLEQ based CPU on FPGA. SUBLEQ (subtract and branch if less than or equal to zero) is an instruction which is universal. However, how can you have immediates/constants with this?

\$\endgroup\$
1
\$\begingroup\$

One way is to have the compiler/assembler store constants at fixed locations in memory that you then access with your instruction by using it as an operand. Since you only have a subtract instruction you would actually load the 2's complement of the constant you need.

This technique was used with computers such as the PDP-8 although you could create some constants with judicious use of the various accumulator instructions.

The PDP-8 only had a 3 bit instruction field so 8 basic instructions. It didn't even have a load accumulator, you had to clear the accumulator then add a constant to it. (Of course you had to have placed that constant into memory in the first place).

This link shows some techniques (including this one) to use the single instruction computer. Using the SUBEQ instructions

\$\endgroup\$
0
\$\begingroup\$

You don't have immediate values available to you. Instead, you have to compute them by cleverly using your subleq instruction.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.