ALP for SUM of 1 to COUNT with Function Call and Input Assumption SUM is a address where curirent sum id stored, ONE is address where valued 1 is stored and COUNT is address where count variable to be stored. ==================================================== Address Instruction 00 START 01 SCAN 02 STORE COUNT 05 CALL SUMMATION 08 CALL PRINTSUMMATION 0B HALT 20 SUMMATION: LOAD COUNT 23 STORE SUM /* S=C;*/ 26 Loop: SUB ONE /* C=C-1;*/ 29 JNZ NEXT; /* if T!=0 jump */ 3C RETURN; 3D Next: LOAD SUM 40 ADD COUNT /* S=S+COUNT;*/ 43 STORE SUM 46 JMP Loop; 50 PRINTSUMMATION:LOAD SUM 53 PRINT /* display S;*/ 54 RETURN 60 0 /*SUM at 60*/ 61 ANY /*COUNT at 61*/ 62 1 /*One at 62*/ ==================================================== Putting Address of varibale and Labels (for both function call & jmp/jnz) ==================================================== Address Instruction 00 START 01 SCAN 02 STORE 61 /*Address of count 61*/ 05 CALL 20 /*SUMMATION= code at address 20*/ 08 CALL 50 /*PRINTSUMMATION=code at address 50*/ 0B HALT 20 SUMMATION: LOAD 61 23 STORE 60 /* Address of SUM= 60 S=C;*/ 26 Loop: SUB 62 /* Address of ONE at 62 C=C-1;*/ 29 JNZ 3D /*NEXT=3D*//* if T!=0 jump */ 3C RETURN; 3D Next: LOAD 60 40 ADD 61 /* S=S+COUNT;*/ 43 STORE 60 46 JMP 26; 50 PRINTSUMMATION:LOAD 60 53 PRINT /* display S;*/ 54 RETURN 60 0 /*SUM at 60*/ 61 ANY /*COUNT at 61*/ 62 1 /*One at 62*/ ==================================================== Putting OPCODE and removing comments ==================================================== Address Instruction 00 1 01 C 02 9 61 05 A 20 08 A 50 0B 2 20 8 61 23 9 60 26 4 62 29 7 3D 3C B 3D 8 60 40 3 61 43 9 60 46 6 26; 50 8 60 53 D 54 B 60 0 61 ANY 62 1 ==================================================== Hex code of Program With Address ==================================================== Address Instruction 00 1 01 C 02 9 61 05 A 20 08 A 50 0B 2 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 8 61 23 9 60 26 4 62 29 7 3D 3C B 3D 8 60 40 3 61 43 9 60 46 6 26; 49 4A 4B 4C 4D 4E 4F 50 8 60 53 D 54 B 55 56 57 57 59 5A 5B 5C 5D 5E 5F 60 0 61 ANY 62 1 ==================================================== Hex code of Program With out Address ==================================================== Address Instruction 1 C 9 61 A 20 A 50 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 61 9 60 4 62 7 3D B 8 60 3 61 9 60 6 26; 0 0 0 0 0 0 0 8 60 D B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1