Tuesday, 14 March 2017

Store 01H, 02H, 03H and 04H in Regiser R0, R1, R2 and R3 respectively and exchange data stored in Reg R0 with R1 and data in Reg R2 with R3

ORG 00H

SJMP START

START : MOV R0,#01H

               MOV R1,#02H

               MOV R2,#03H

               MOV R3,#04H

               MOV A,R0

               XCH  A,R1

               MOV  R0,A

               MOV  A,R2

               XCH  A,R3

               MOV  R2,A

STOP :   SJMP STOP

               END


Friday, 25 October 2013

program to find factorial of a given no.

        ORG 000H
        SJMP START
        RESH EQU 30H
        RESL EQU 30H
        TEMP EQU 50H
START : MOV A,#_H  /* ENTER THE NO. TO FIND THE FACTORIAL */
        MOV R0,#31H
        MOV RESL,A
        MOV R1,A
ABOVE : DJNZ R1,DOWN
        SJMP EXIT
 DOWN : ACALL MULTIPLY
        SJMP ABOVE
 EXIT : SJMP EXIT

MULTIPLY : MOV A,@R0
           MOV B,R1
           MUL AB
           MOV @R0,A
           MOV TEMP,B
           DEC R0
           MOV A,@R0
           MOV B,R1
           MUL AB
           ADD A,TEMP
           MOV @R0,A
           INC R0
           RET END

Monday, 7 October 2013

program to convert hexadecima(8-bit) to BCD

        ORG 000H
        SJMP START
        HUN EQU 30H
        TEN EQU 31H
        UNIT EQU 32H
START : MOV HUN,#00H
        MOV TEN,#00H
        MOV UNIT,#00H
        MOV A,#_H
   UP : CLR C
        SUBB A,#64H
        JC L1
        INC HUN
        SJMP UP1
   L1 : ADD A,#64H
  UP2 : CLR C
        SUBB A,#0AH
        JC L2
        INC TEN
        SJMP UP2
   L2 : ADD A,#0AH
        MOV UNIT,A
 STOP : SJMP STOP
        END 

program to convert hexadecimal to ascii

        ORG 000H
        SJMP START
        RESULT EQU 30H
START : MOV A,#_H  /*enter the number to convert*/
        MOV B,A
        CLR C
        SUBB A,#0AH
        JC SKIP
        MOV A,B
        ADD A,#37H
        SJMP DOWN
 SKIP : MOV A,B
        ADD A,#30H
 DOWN : MOV RESULT,A
 STOP : SJMP STOP
        END

OUTPUT :

sl.no      HEX no.        ASCII
 1          01H            31
 2          03H            33
 3          0AH            41

Saturday, 28 September 2013

program to check given 8-bit data is "2 out of 5 code" or not

Before we write the program to check whether the given 8-bit data is "2 out of 5 code" or not, let us first understand what is meant by 2 out of 5 code. An 8-bit is 2 out of 5 code if and oly if its 3 MSB bits are zero and the remaining 5 bits contains two 1's. You will be able to understand clearly from the following example shown below.


 let us take the 8 bit data as 18

18 = 0001 1000
         1      8

so in the above example the 3 MSB bits(i.e first 3 bits) are zero & there are two 1's in remaing 5 bits. so that makes the given 8-bit 2 out of 5 code.


Program :
// If given 8 bit is 2 out of 5 code store FFH in memory location 30H//
//If no, store 00H in memory location 30H//


        ORG 00H
        SJMP START
        RESULT EQU 30H
START : MOV A,#_H
        MOV B,A
        ANL A,#0E0H
        JNZ EXIT
        MOV A,B
        MOV R0,#05H
        MOV R1,#00H
   UP : RRC A
        JNC DOWN
        INC R1
 DOWN : DJNZ R0,UP
        MOV A,R1
        CJNE A,#02H,EXIT
        MOV RESULT,#0FFH
        SJMP STOP
 EXIT : MOV RESULT,#00H
 STOP : SJMP STOP
        END






program to perform multiplication of two 8 bit no.s using successive addition method

        ORG 000H
        SJMP START
        RESL EQU 30H
        RESH EQU 31H
START : MOV A,#00H
        MOV B,#_H      /*enter 1st no. */
        MOV R0,#_H     /*enter 2nd no. */
   UP : ADD A,B
        JNC DOWN
        INC RESH
 DOWN : DJNZ R0,UP
        MOV RESL,A
 STOP : SJMP STOP
        END


output :

sl.no  N1    N2    RESH   RESL
      (1st no.)  (2nd no.)  (31H)        (30H)

 1.    8     32     1     90
 2.    6     12     0     6C
 3.    9     14     0     B4    

Thursday, 19 September 2013

program to find bigger no. in a list of given no.s

        ORG 000H
        SJMP START
        RESULT EQU 30H 
START : MOV R0,#30H
        MOV R1,#05H  /* R1 declared as a pass counter*/
        MOV B,@R0
   UP : INC R0
        MOV A,@R0
        CLR C
        SUBB A,B
        JC SKIP
        MOV B,@R0
 SKIP : DJNZ R1,UP
        MOV RESULT,A
 STOP : SJMP STOP