_main:
mov r0,#0x0f ; R0 is loaded with value ‘15’
$300:
mov r1,#0x0f ; R1 is loaded with value ‘15’
mov b,#0x00 ; Register B is loaded with ‘00’
mov dptr,#0x000 ; Data pointer is loaded with value ‘0000’
$200:
movx a,@dptr ; The content of the address location as indicated by data pointer is copied to Accumulator
xch a,b ; Exchange the contents of accumulator and register B
inc dptr ; Increment Data Pointer
movx a,@dptr ; The content of the next address location as indicated by data pointer is copied to Accumulator
anl p2,#0x80 ; Logically AND the value at Port P2 with value’80’
mov r7,p2 ; The result of AND operation is copied from Port P2 to R7
cjne r7,#0x80,loop ; Check whether the value in R7 is equal to ‘80’. If not, jump to loop
loop3:
cjne a,b,loop2 ; Check whether the content of Accumulator and register B are equal. If not, jump to loop2
loop2:
jnc $100 ; Check whether Accumulator content is less than the data in register B. If not, jump to label $100
sjmp skip ; Jump to loop skip
loop:
cjne a,b,loop1 ; Check whether the content of Accumulator and register B are equal. If not, jump to loop1
loop1:
jc $100 ; Check whether Accumulator content is less than the data in register B. If yes, jump to label $100
skip:
dec dpl ; Decrement Data Pointer
movx @dptr,a ; Move the content of Accumulator to the address location indicated by Data Pointer
inc dptr ; Increment Data Pointer
xch a,b ; Exchange the contents of accumulator and register B
movx @dptr,a ; Move the content of Accumulator to the address location indicated by Data Pointer
$100:
djnz r1,$200 ; Check whether R1 is zero. If not jump to label $200
djnz r0,$300 ; Check whether R0 is zero. If not jump to label $200
mov r2,#0x10 ; R2 is loaded with value ‘10’
mov p1,#0x00 ; The value ‘00’ is loaded to Port P1
mov dptr,#0x000 ; Data pointer is loaded with value ‘0000’
$400:
movx a,@dptr ; The content of the address location as indicated by data pointer is copied to Accumulator
mov p1,a ; Accumulator content is copied to Port P1
mov r3,#0x5 ; R3 is loaded with value ‘50’
$500:
djnz r3,$500 ; Check whether R3 is zero. If not jump to label $500
inc dptr ; Increment Data Pointer
djnz r2,$400 ; Check whether R2 is zero. If not jump to label $400
00101$:
ret ; Return
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.