Computer Architecture 1
Assembly Language Programming Lab
Write a program to calculate the sum of first ten natural
Program 4:
numbers.
Program:
Memory Opcode &
Mnemonics Comments
Address Operand
2000 LDA 3500 Load the input data from memory location 3500.
2001
2002
2003 MOV B, A Move the content of Register A into Register B
2004 INR A Increment the content of Register A
2005 MOV C, A Move the content of Register A to Register C
2006 MVI A, 00 Move the 8 bit data (00) into Accumulator
2007
2008 ADD B
Add the content of register B to content of
[Loop1] Accumulator
2009 DCR C Decrement the content of register C
200A JNZ 2008 Jump No Zero to memory location 2008
[Loop1]
200B
200C
200D MVI C, 02 Move immediate 8 bit data (02) into register C
Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re
Computer Architecture 2
Assembly Language Programming Lab
200E
200F MVI B, 00 Move immediate 8 bit (00) into register B
2010
2011 INR B Increment the content of register B
[Loop2]
Subtract the content of Register C from the content
2012 SUB C
of Accumulator.
2013 JNZ 2011 Jump No Zero to memory location 2011.
[Loop2]
2014
2015
2016 MOV A, B Move the content of register B to register A
Store the content of Accumulator in memory
2017 STA 3501
location 3501
2018
2019
201A HLT Stop the program execution.
Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re
Computer Architecture 3
Assembly Language Programming Lab
Execution:
Example
Memory Address Input Output
First n natural
3500 0A --
number
3501 -- 37H
___________________________E n d o f P r o g r a m 4 ____________________________
Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re