You are on page 1of 17

3/20/12

;WAP TO SUBSTRACT TWO 16 BIT NUMBERS STORED IN 40-41H AND 50-51H MEMORY LOCATIONS AND SAVE THE RESULT IN R2 AND R3 REGISTERS.

ORG 0000H CLR C MOV R0, #40H MOV R1, #50H MOV A,@R0 SUBB A, @R1 MOV R2,A MOV R0,#41H MOV R1,#51H MOV A,@R0 SUBB A,@R1 MOV R3,A CLR A RLC A MOV R4,A END
3/20/12

3/20/12

3/20/12

Click to edit Master subtitle style

3/20/12

3/20/12

3/20/12

wap to implement an 8bit hex down counter.

ORG 00H MOV A,#00H BACK: ACALL DELAY DEC A JNZ BACK SJMP LAST DELAY: MOV R0,#0FFH LOOP2: MOV R1,#0FFH LOOP1: MOV R2,#0FFH HERE: DJNZ R2,HERE DJNZ R1,LOOP1 DJNZ R0,LOOP2 RET LAST: END
3/20/12

3/20/12

wap to implement an 8bit bcd down counter.

ORG 00H MOV A,#00H BACK: ACALL DELAY ADD A,#99H DA A JNZ BACK SJMP LAST DELAY: MOV R0,#0FFH LOOP2: MOV R1,#0FFH LOOP1: MOV R2,#0FFH HERE: DJNZ R2,HERE DJNZ R1,LOOP1 DJNZ R0,LOOP2 RET LAST: END
3/20/12

;Write an ALP to find whether the give Number ODD or EVEN Number ;IF EVEN NUMBER STORE A=0 AND IF ODD NUMBER STORE A=1

ORG 0000H MOV A,40H RRC A MOV A,#00H ADDC A,#00H END

3/20/12

Write an ALP to find Numbers of 1's and 0's in a byte stored in 40h memory location ORG 0000H MOV R0,#00H MOV R1,#00H MOV R2,#08H MOV A,40H UP:RLC A JNC N1 INC R1 JMP N2 N1:INC R0 N2:DJNZ R2,UP END
3/20/12

;WAP TO GENERATE 10 FIBONACCI NUMBERS AND STORE RESULT FROM 30H

org 0000h mov r0, #30h mov r1, #08h mov @r0, #00h inc r0 mov @r0, #01h mov a,@r0
3/20/12

/*Two eight bit numbers NUM1 & NUM2 are stored in external memory locations 8000h & 80001h respectively. Write an ALP to compare the 2 nos. Reflect your result as: if NUMI<NUM2, SET LSB of Register A IF NUM1>NUM2, SET MSB OF Register A. if NUM1 = NUM2-Clear both LSB & MSB of Register A*/ ORG 0000H MOV DPTR,#8000H MOVX A,@DPTR MOV R0,A INC DPTR MOVX A,@DPTR CLR C SUBB A,R0 JZ EQUAL JNC BIG MOV A,#01H SJMP END1 BIG:MOV A,#80H SJMP END1 EQUAL:MOV A,#00H END1: END 3/20/12

/*3 eight bit numbers X, NUM1 & NUM2 are stored in internal data RAM locations 20h, 21h & 22H respectively. Write an ALP to compute the following. IF X=0; THEN 23H=NUM1 (AND) NUM2, IF X=1; THEN 23H=NUM1 (OR) NUM2, IF X=2; THEN 23H=NUM1 (XOR) NUM2, ELSE 23H =00*/ ORG 0000H MOV A, 20h //donot use #, as data ram 20h is to be accessed MOV R1,A //X IN R1 MOV A,21H //A -NUM1 CJNE R1,#0,CKOR ANL A, 22H SJMP END1 CKOR:CJNE R1,#01,CKXOR ORL A, 22H SJMP END1 CKXOR:CJNE R1,#02,OTHER XRL A, 22H SJMP END1 OTHER: CLR A END1: MOV 23H,A //STORE RESULT HERE: SJMP HERE END 3/20/12

eight bit numbers X, NUM1 & NUM2 are stored in internal data RAM locations 20h, 21h & 22H respectively. Write an ALP to compute the following. IF X=0; THEN LSB OF NUM1 (AND) LSB OF NUM2, IF X=1; THEN MSB OF NUM1 (OR)MSB OF NUM2 , IF X=2; THEN COMPLEMENT MSB OF NUM1 STORE THE BIT RESULT IN MSB OF 23H LOCATION*/ ORG 00H MOV R0,20H //R0-X CJNE R0,#0,CK1 MOV C,08H //LSB OF NUM1 (21H) - BIT ADDRESS -08 ANL C,10H //LSB OF NUM2 (22H) - BIT ADDRESS -10 SJMP LAST CK1:CJNE R0,#1,CK2 MOV C,0FH //MSB OF NUM1 (21H) - BIT ADDRESS -0F ANL C,17H //MSB OF NUM2 (22H) - BIT ADDRESS -17 SJMP LAST CK2:CJNE R0,#2,CK3 CPL 0FH MOV C,0FH //MSB OF NUM1 (21H) - BIT ADDRESS -0F SJMP LAST CK3:CLR C LAST:MOV 1FH,C //RES IS MSB OF 23H LOCATION -1FH HERE:SJMP HERE 3/20/12 END

/*3

;Write an ALP to perform the following: ;If x=0-perform A=W+V; else if x=1-perform A=W-V; else if x=2-perform A=W*V; elseif x=3-perform A=W/V, ;where x=40H, W=41H & V=42H memory locations AND A=Accumulator. ORG 0000H X EQU 40H W EQU 41H V EQU 42H MOV R1,X //R1 HAS CONDITION X MOV A,W //A HAS 1ST NUMBER-w MOV B,V //B HAS 2ND NUMBER-v CJNE R1,#00,CKSUB ADD A,B //PERFORM ADDITION SJMP LAST CKSUB: CJNE R1,#01,CKMUL CLR C //RESET BORROW FLAG SUBB A,B SJMP LAST CKMUL: CJNE R1,#02,CKDIV MUL AB //16 bit product in AB with A having lower byte SJMP LAST CKDIV: CJNE R1,#03,OTHER DIV AB //Quotient in A & remainder in B SJMP LAST OTHER:MOV A,#00 MOV B,#00 LAST: 3/20/12 END

You might also like