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 here

end

4c

org 000h

 sjmp 30h

 org 30h

 mov a,50h ; load the ASCII number to accumulator from 50h

 cjne a,#40h,label ; check the ASCII number is > 40

label: jc exit 

 clr c

 subb a,#37h ; if > 40 subtract 37h to convert to hex value and save at 51h

 sjmp last

exit : clr c

 subb a,#30h ; else subtract 30h to convert to hex value and save at 51h

 last: mov 51h,a

sjmp $

end


4d


org 000h

sjmp 30h

org 30h

mov a,50h ; load accl the decimal number from 50h

anl a,#0fh

add a,#30h ;mask upper byte

mov 52h,a ; save ASCII value of LS byte of number to 52h

mov a,50h

anl a,#0f0h

swap a

add a,#30h

mov 51h,a ; save ASCII value of MS byte of number to 52h

H:sjmp H

End


4e

org 0000h

sjmp 30h

org 30h

mov a,50h ; load to accul the hexadecimal number from 50h

mov b,#0ah ; load B reg=10

div ab ; divide

mov 61h,b ; save reminder i.e MSdigit2 of decimal number at 61h

mov b,#0ah

div ab ; divide quotient at A register by 10

mov 60h,a ; save quotient at 60h i.e. MSdigit1 of decimal number

mov a,b

swap a

add a,61h

mov 61h,a ; save reminder at 61h i.e LS digit of decimal number

sjmp $

end

4f

org 0000h

sjmp 30h

org 30h

mov r0,# 50h ;pointer to decimal number

mov r2,50h ;save the decimal num at mem.locn to r2 reg

mov a,@r0

anl a,#0f0h ;mask lower nibble of decimal number

swap a ;get upper nibble of decimal number

 mov 0f0h,#10

 mul ab ;multiply ms digit of the decimal num by 10

 mov r3,0f0h ;save upper byte at r3 reg

 mov r4,a ;save lower byte at r4 reg.

 mov a,r2 ;get the decimal num from r2 reg to acc.

 anl a,#0fh ; mask upper nibble of decimal number

 add a,r4 ; add lower byte

 mov 51h,a ; save result at mem.location 51h

 sjmp $

 end


Comments

Popular posts from this blog

p-3

p-5

p-2