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 ; store src addr at r2 & r3

mov r3,dpl

mov dph,r0 ; get the dest addr to dptr

mov dpl,r1

movx @dptr ; transfer from ‘a’ to dest addr

inc dptr

mov r0,dph ; store dest address at r0 & r1

mov r1,dpl

mov dph,r2 ; get back src addr to dptr

mov dpl,r3

djnz r7,back ; decrement counter if r7≠0,continue the data transfer

here: sjmp here ; r7=0, all the data are transferred .

end

1c

org 0000h ; PC loaded with 0000h the starting address of code memory
 location
sjmp 30h 
org 30h
mov r0,#50h ;r0 pointing to one block of data at 50h (internal RAM)
mov r1,#60h ;r1 pointing to another block of data at 60h
mov r7,#10h ; initialize r7=10h, as counter the no. of data to be exchanged
back: mov a,@r0 ; exchange the data between one locn with another locn. 
xch a,@r1
mov @r0,a
inc r0
inc r1
djnz r7,back ;decrement counter, if r7≠0,continue the exchange of data 
here: sjmp here ; r7=0 and data exchange is completed
 end

1d

org 0000h
sjmp 30h
org 30h
mov r0,#50h ; r0 is pointing to array of data stored at 50h
mov r7,#0Ah ;initialise a counter r7=0Ah
mov a, #00h ;mov a,#0ffh for smallest
again: mov b,@r0
cjne a,b,label ;compare -data at A register > data at B register
sjmp next
label: jnc next ;for smallest use jc instruction
mov a,b ;save the largest no.at A register
mov r4,00h ;save its position at reg r4(00h-direct address of r0)
next: inc r0
djnz r7,again ;check the largest among all the elements in the array
mov 60h,a ; save the largest number at 60h data memory location
mov 61h,04h ;save its position at 61h data memory location from
 ; r4-Direct address
sjmp $
end

1e

org 0000h
sjmp start
org 30h
start: mov r0,#50h ;r0 is pointing to unsorted array of data stored at 50h
mov r2,#09h ;load r2=09h the pass counter(count=total num-1)
outer: mov r3,#09h ;load r3=09h the comparison counter(count=total num-1)
inner: mov b,@r0
 inc r0
mov a,@r0 ;compare two data’s, if contents of A register is greater
cjne a,b,next ; than B register exchange ,else check with the next data
next: jc nochange ;JNC for Ascending order
mov @r0,b
dec r0
mov @r0,a
inc r0
nochange: djnz r3,inner ; decrement comparison counter until r3=0 
mov r0,#50h
djnz r2,outer ; decrement pass counter 
sjmp $
end





Comments

Popular posts from this blog

p-3

p-5

p-2