87
DEC R0 ; point to next source
DEC R1 ; point to next destination
DJNZ R7, SHIFT ; loop on eight times
; R7 indicates that the operation is over.
; Next instruction is used to terminate the program.
OVER: SJMP OVER ; terminate here.
Please note that had it been a case of shifting down, pointers would have been loaded for the other end (50H
and 4FH) and would have been incremented after every iteration.
C-version
#include <regx51.h>
void main(void)
{
unsigned char *src, *dst;
signed char ptr; // note we take signed data type here
src = 0x50; // point fi rst location of source
dst = 0x51; // point fi rst location of destination
for (ptr = 7; ptr >= 0; ptr --)
{
dst[ptr] = src[ptr];
}
while(1);
}
7.4 | Count No. of Nulls ...