ALP for SUM of 1 to COUNT Assumption SUM is a address where curent sum id stored, ONE is address where valued 1 is stored and COUNT is address where count variable is stored. ==================================================== Address Instruction 00 START 01 LOAD COUNT 04 STORE SUM /* S=C;*/ 07 Loop: SUB ONE /* C=C-1;*/ 0A JNZ NEXT; /* if T!=0 jump */ 0D LOAD SUM 10 PRINT /* display S;*/ 11 HLT 12 Next: LOAD SUM 15 ADD COUNT /* S=S+COUNT;*/ 18 STORE SUM 2B JMP Loop; ========================================================================= Putting Label properly (Address) ==================================================== Address 00 START 01 LOAD COUNT 04 STORE SUM 07 Loop: SUB ONE 0A JNZ 12; /* Address of NEXT Label =12 */ 0D LOAD SUM 10 PRINT 11 HLT 12 Next: LOAD SUM 15 ADD COUNT 18 STORE SUM 2B JMP 07; /*Address of Loop Label =07*/ ========================================================================= Putting Address of variable Properly Assumption variable COUNT stored at 2C, SUM stored at 2D, Value 1 stored at 2E Assume value of COUNT=4 ==================================================== Address 00 START 01 LOAD 2C 04 STORE 2D 07 Loop: SUB 2E 0A JNZ 12; /* Address of NEXT Label =12 */ 0D LOAD 2D 10 PRINT 11 HLT 12 Next: LOAD 2D 15 ADD 2C 18 STORE 2D 2B JMP 07; /*Address of Loop Label =07*/ 2C 4 /*Count value stored*/ 2D 0 2E 1 /*value 1 stored*/ ========================================================================= Convert All Nemonics to OPCODE ==================================================== Address 00 1 01 8 2C 04 9 2D 07 Loop: 4 2E 0A 7 12; /* Address of NEXT Label =12 */ 0D 8 2D 10 D 11 2 12 Next: 8 2D 15 3 2C 18 9 2D 2B 6 07; /*Address of Loop Label =07*/ 2C 4 2D 0 2E 1 ==================================================== Final Program Hex code without Address ==================================================== 1 8 2C 9 2D 4 2E 7 12; 8 2D D 2 8 2D 3 2C 9 2D 6 07; 4 0 1