Back to DFS's Workshop Page
Back to Agenda Page


Register Multiplication Problem

This problem is part of the larger CPU Register Math project. It will simulate how multiplication can be performed with the 8-bit register 6502 CPU.

For this problem, you are to cannibalize any available code and write a pair of scripts which will accept decimal inputs for the multiplicand and multipier from the user and show how registers in the CPU can be used to find the product of their binary equivalents.

Your code should produce representations of the CPU registers which look like the one below.

Add Register X to Register A

A00000000
X00000011
Y????????

Provide a short description of the action being taken.

To indicate which register has just been manipulated, display the row entries in red.

If a register has not as yet been used, have a query (?) represent each bit. (In reality, each bit in the CPU would contain a 1 or 0.)

Your solution should utilize two scripts.

  1. The data entry script: multiply.html
    1. Explain the purpose of the scripts
    2. Accept the multiplicand and multiplier as inputs in a form
    3. Using a "Multiply!" button, send the data to a PHP script called multiply.php
  2. The simulation page: multiply.php
    It should have four steps, the last of which is executed repeatedly and contains two steps.
    1. Zero out the accumulator
    2. Load the multiplicand into the X register
    3. Load the multiplier into the Y register
    4. Until the value in the Y register is zero,
      1. Add the value in the X register to the one in the accumulator, putting the result in the accumulator
      2. Decrement the value in the Y register

To see how this could work, view this possible solution.

Notes


© 2006 DFStermole
Created 7 Jan 06
Last Modified 7 Jan 06