// // multiply program for simple processor // This processor supports direct and immediate addressing // // Define locations of I/O devices 2048,2049 SWITCHES EQU 2048 LEDS EQU 2049 // Define locations of variables 256-258 VAR_Op1 EQU 256 VAR_Op2 EQU 257 VAR_Res EQU 258 // Program starts by default at location 0 .start LDA SWITCHES // copy low byte to Operand1 AND #255 STA VAR_Op1 LDA SWITCHES // copy high byte to Operand2 LSR LSR LSR LSR LSR LSR LSR LSR STA VAR_Op2 LDA #0 // copy zero to Result STA VAR_Res .loop LDA VAR_Op2 // exit loop if Operand2 is zero JMPZ .done SUB #1 // decrement Operand2 STA VAR_Op2 LDA VAR_Res // Result <- Result + Operand1 ADD VAR_Op1 STA VAR_Res JMP .loop // end of loop .done LDA VAR_Res // copy Result to LEDs STA LEDS // Endless loop .end JMP .end