Posts

Assembly language program to take the input of of N numbers from memory location 2201 and store sum of even number at 2210 and sum of odd number at 2211

Program: LDA 2200 MOV C,A   ;C=4 MVI B,0   ;B=0 FOR EVEN MVI D,0   ;D=0 FOR ODD LXI H,2201    BACK: MOV A,M     ;A=1 FROM 2201,A=2,3,4 ANI 01            ;AND 01 WITH A FOR CHECKING EVEN OR ODD JNZ ODD          ; ODD IF NOT 0 THAT IS 1,0,1,0   MOV A,B           ;FOR EVEN   A=B=>0,2   ADD M             ;A=A+M=>0+2=2 ,2+4=6 MOV B,A           ;NOW B=2,6 JMP NEXT         ; NEXT ADDRESS ODD: MOV A,D      ;A=D=>0,1 ADD M             ;A=A+M=>0+1=1,1+3=4 MOV D,A           ;D=A=>1,4 NEXT: INX H    ;...

Assembly language program for Fibonacci Series

Program: LXI H,3050   MVI D,10     ; D is counter (D=10) MVI B,00     ; B=00 MVI C,01     ; C=01 MOV M,B    ; Copy the content of B at memory location 3050 that is 00 INX H           ; increment the HL pair that is 3051   MOV M,C    ; Copy the content of C at memory location 3051 that is 01 LOOP: MOV A,B   ; now A=B =00 ADD C           ;   A=A+C   => A=0+1=1   MOV B,C      ; B=C=> 1 MOV C,A     ;   C=A=>1 INX H           ; increment the HL pair that is 3052 MOV M,A   ;   Copy the content of A at memory location 3052 that is 01 DCR D          ; Decrement counter that become 9 JNZ LOOP    ; g...

Assembly language program for factorial of number 0,1,2,3,4, 5,6,7 and 8

Program: lxi h,0000H; mov D,m; INR D; MVI B,1; MVI C,0; MVI E,0; MVI L,1; LOOP:     MVI A,0;     LOOP1: ADD L;         JNC NOCARRY;         INR C;         NOCARRY: DCR B;         JZ NEXT;     JMP LOOP1;     NEXT: MOV E,A;         MOV A,L;         INR A;         CMP D;         JZ END;         INR L;         MOV B,E;         MOV H,C;                MVI A,0;         PRECARRY: ADD L;         DCR H;       ...