// // 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 @0032 ORG 50 @0032 0000 CONST_0 FCW 0 @0033 0001 CONST_1 FCW 1 @0034 00ff CONST_255 FCW 255 // Program starts at location 0 @0000 ORG 0 @0000 4800 .start LDA SWITCHES // copy low byte to Operand1 @0001 7034 AND CONST_255 @0002 f100 STA VAR_Op1 @0003 4800 LDA SWITCHES // copy high byte to Operand2 @0004 b000 LSR @0005 b000 LSR @0006 b000 LSR @0007 b000 LSR @0008 b000 LSR @0009 b000 LSR @000a b000 LSR @000b b000 LSR @000c f101 STA VAR_Op2 @000d 4032 LDA CONST_0 // copy zero to Result @000e f102 STA VAR_Res @000f 4101 .loop LDA VAR_Op2 // exit loop if Operand2 is zero @0010 2017 JMPZ .done @0011 6033 SUB CONST_1 // decrement Operand2 @0012 f101 STA VAR_Op2 @0013 4102 LDA VAR_Res // Result <- Result + Operand1 @0014 5100 ADD VAR_Op1 @0015 f102 STA VAR_Res @0016 100f JMP .loop // end of loop @0017 4102 .done LDA VAR_Res // copy Result to LEDs @0018 f801 STA LEDS @0019 1063 JMP .end // Endless loop at location 99 @0063 ORG 99 @0063 1063 .end JMP .end