1 Write to program to perform the followings You can use the
1. Write to program to perform the followings. You can use the instructions bne and decb.
A. Clear accumulator B
B. add 5 to B 100 times.
Show step by step please and is HCS112 coding for all parts.
Solution
A)
ORG 100 //program loaded into address 100
MOV B,#OOH //clearing accumilator B
 LDA SUM //loading SUM
 ADD SUM,5 //addign 5 to sum
 STA SUM //saving SUM
B)
import static javax.swing.JOptionPane.*;
 public class Gauss2
 {
 public static void main( String args [ ] )
    {
       // input n
       String prompt = \"Enter n: \";
       String input = showInputDialog( prompt );
       int n = Integer.parseInt( input );
       // calculate sum
       String output = \"\"; // start output str
       int sum = 0;        // start sum
       for ( int k = 1; k <= n; k++ )
       {
           for(int j = 1 ; j <= k; j++ ){
                 sum = sum + 5 ;
            }
       }
       // output final answer
       output += \" = \" + sum;
       showMessageDialog( null, output );
    }
 }
if u enter n value 5.then it prints 5+10+15+20+25=75

