Posts

Showing posts from September, 2022

p-6

6a  1.Interrupt with level triggering org 0000h sjmp 0030h ;main program  --------------interrupt service routine for INT1 to turn on/off led org 0013h ;INT1 vector address mov p0,#0aah ;LED ON/OFF mov r4,#255 ;delay for 1 sec repeat: mov r5,#255  next: mov r6,#04h  c2: djnz r6,c2 djnz r5,next djnz r4,repeat mov p0,#55h ;LED ON/OFF reti ; return on interrupt  ---------------main program for initialization  org 0030h mov p0,#00 ;configure port as output port mov ie,#10000100b ; enable external interrupt 1 here: sjmp here ;stay here until interrupted end 2.Interrupt with edge triggering org 0000h sjmp 0030h ;main program  -----------interrupt service routine for INT1 to turn on/off led org 0013h ;INT1 vector address mov p0,#0aah ;LED ON/OFF mov r4,#255 ;delay for 1 sec repeat: mov r5,#255  next: mov r6,#04h  c2: djnz r6,c2 djnz r5,next djnz r4,repeat mov p0,#55h ;LED ON/OFF reti ; return on interrupt ---------------main program for initializati...

p-5

 5a org 0000h sjmp 30h org 30h mov a,#34h ACALL double here:sjmp here  double: ADD A,#0E0h LCALL invert ret org 5000h  invert: XRL a,#0ffh ret end 5b org 0000h sjmp start  Start: clr P1.0 ; p1.0=0(low)  back: cpl P1.0 acall delay sjmp back  delay: mov r4,#0e5h ; this count generates a delay of 0.5 ms   here: djnz r4,here  ret  end 5c a). (Generate a delay of 1ms)  org 0000h  Sjmp 30h  org 30h  mov tmod ,#10h ;configure timer 1 in mode 1  clr p1.1 mov th1,#0fch ;this count gives a delay of 1ms.  mov tl1,#66h cpl p1.1  Setb tr1 ; start timer  here: jnb tf1, here clr tf1 clr tr1 clr p1.1  next: sjmp next end (b) Generate a square wave of 2KHz frequency (each delay of 0.25ms) org 0000h Sjmp start  Start: mov tmod ,#20h ;configure timer 1 in mode 2(auto reload)  mov th1,#1ah ;this count gives a delay of 1ms.  clr p1.1  next: cpl p1.1  Setb tr1 ; start timer  here: jnb ...

p-4

 4a org 0000h  sjmp 30h org 30h start: mov p2,#00h ;Initialize port P2 as O/P port and port P1 as I/P port  mov p1,#0ffh ;read port P1 as d=P1.0,c=P1.1,b=P1.2,a=P1.3 repeat: jnb p1.3 ,second ;check if variable a=0,if 0 check c and d  jnb p1.2,second ;check if variable b=0 ,if 0 check c and d  setb p2.0 ; if a=1,b=1 set o/p z=1   sjmp repeat ;if true read port P1i.e next i/p  second: jb p1.1,false ;check if c=1  jb p1.0,false ;check if d=1 setb p2.0 ;if c=0,d=0 set o/p z=1 sjmp exit ;repeat for next set of i/p false: clr p2.0 ;if a=0,b=0,c=1,d=1 clear o/p i.e z=0 exit: sjmp repeat ;read port for the next combination of input end 4b org 000h sjmp 30h org 30h mov a,50h ; load to accumulator the BCD number from data memory location  50h anl a,#0fh add a,#30h mov 61h,a ;store the lower nibble ACSII value in higher address mov a,50h anl a,#0f0h swap a add a,#30h mov 60h,a ;store the higher nibble ACSII value in lower address  here: sjmp h...

p-3

 3a org 0000h sjmp 30h org 30h mov p1,#00h ;configure p1 as o/p port mov a,#00h back: mov p1,a ;load p1 with initial count acall delay ; give delay between count inc a ;add 01 to increment the count sjmp back  delay: mov r4,#0ffh ;delay between counts repeat: mov r5,#0ffh next: mov r6,#04h l1: nop djnz r6,l1 djnz r5,next djnz r4,repeat ret end 3b org 0000h sjmp 30h org 30h mov p1,#00h ;configure p1 as o/p port mov a,#0ffh back: mov p1,a ;load p1 with initial count acall delay ; delay between count dec a ;subtract 01 to decrement the count sjmp back delay: mov r4,#0ffh ;delay between counts repeat: mov r5,#0ffh next: mov r6,#04h l1: nop djnz r6,l1 djnz r5,next djnz r4,repeat ret end 3c org 0000h sjmp 30h org 30h mov p1,#00h ;configure p1 as o/p port mov a,#00h back: mov p1,a ;load p1 with initial count acall delay ; delay add a,#01 ;add 01 to increment the count  da a sjmp back delay: mov r4,#0ffh ;delay between counts repeat: mov r5,#0ffh next: mov r6,#04h l1: nop djnz r6...

p-2

 2a org 0000h  sjmp 30h  org 30h mov r0,#51h ;r0 pointed to internal RAM loc 51h (LS byte of data1) mov r1,#53h ;r1 pointed to internal RAM loc 53h (LSbyte of data2) clr c mov a,@r0 ;perform LS byte addition save the result at 62h location  add a,@r1 dec r0 dec r1 mov 62h,a mov a,@r0 ;perform MS byte addition save the result at 61h loc addc a,@r1 mov 61h,a jnb 0D7h, skip ; JNB 0D7h,target is bit addressable instruction equivalent  to JNC instruction  mov 60h,#01h ; if carry is there after addition save carry at 60h loc  sjmp here skip: mov 60h,#00h here: sjmp here  end 2b org 0000h  sjmp 30h  org 30h mov r0,#51h ;r0 pointed to internal RAM loc 51h (LS byte of data1) mov r1,#53h ;r1 pointed to internal RAM loc 53h (LS byte of data2) clr c mov a,@r0 ;perform LS byte subtraction save the result at 62h location  subb a,@r1 dec r0 dec r1 mov 62h,a mov a,@r0 ;perform MS byte subtraction save the result at 61h loc subb a,@r1 mov 61h,a jnb ...

1(a,b)

1a: Org 0000h ;PC loaded with 0000h the starting address of code memory Sjmp 30h Org 30h mov r0,#50h ;r0 pointing to source block at 50h (internal RAM) mov r1,#60h ;r1 pointing to destination block at 60h mov r2,#10h ;r2 loaded with no. of elements in the array back:   mov a,@r0 ;data transfer from src block to accumulator and  mov @r1,a ;then to dst block inc r0 ;increment pointers. inc r1 djnz r2,back ;decrement r2,if not equal to 0,continue with data   ;transfer process.  here: sjmp here  end 1b org 0000h ;PC loaded with 0000h the starting address of code  memory location  sjmp 30h  org 30h mov dptr,#8050h ;DPTR pointed to external RAM location 8050h(source)  mov r0,# 80h ;save destination location 8060h at r0 and r1  mov r1,#60h mov r7,#10h ;load the no. of data to be transferred to r7=05h(bytes) back: movx a,@dptr ; transfer the data from src location 8050h to accumulator inc dptr ; increment src pointer. mov r2,dph ; stor...