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