// // multiply program for simple processor // // 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 // Define locations of constants 50-52 ORG 50 CONST_0 FCW 0 CONST_1 FCW 1 CONST_255 FCW 255 // Program starts at location 0 ORG 0 .start LDA SWITCHES // copy low byte to Operand1 AND CONST_255 STA VAR_Op1 LDA SWITCHES // copy high byte to Operand2 LSR LSR LSR LSR LSR LSR LSR LSR STA VAR_Op2 LDA CONST_0 // copy zero to Result STA VAR_Res .loop LDA VAR_Op2 // exit loop if Operand2 is zero JMPZ .done SUB CONST_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 JMP .end // Endless loop at location 99 ORG 99 .end JMP .end