This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

clarity of dual dptr code

to make an assembly routine clearer to read, I want to indicate which of the 2 dptrs are used in each instance. One is fetch, another is store.

So, to achieve that, I insert the following:

 fptr equ   dptr
sptr equ   dptr

And these lines error out.

and below it could be

 movx a,@fptr
mov r7,a
inc fptr
inc auxr1
movx a,@sptr
orl a,r7
movx @sptr,a
inc sptr
inc auxr1

Obviously I can do two macros FETCH and STORE, That, however would not support the identical name when mov dptr,# is there, and as seen in the above 3 macros (or 4 or 5) would be needed.

Is there a way to do this other than the above?

Erik

PS the actual code is far more complicated than the above example.

Parents
  • If you want to improve on this, I think what you really need would be a set of *four* macros:

    	RDP0
    	WDP0
    	RDP1
    	WDP1

    where each of these either "R"eads or "W"rites DPTR #0 or #1, respectively, and a fifth one

    	TO_DPTR a

    that switches over to use of DPTR #0 or #1 depending on the argument passed.


    The tricky bit is to teach these macros which DPTR is the currently selected one, so they can generate

    	inc DPS
    or
    	dec DPS

    (or what ever your architecture uses to select one DPTR) if and only if they're needed. You'ld need a status variable to control this, and make sure you have a TO_DPTR after every entry point callable from the outside.

    In my experience, this is typically not worth the effort --- just write a comment explaining which DPTR you're actually referring to in a given instruction, and religiously use the distinction between inc DPS and dec DPS to indicate which direction a DPS change is meant to take.

Reply
  • If you want to improve on this, I think what you really need would be a set of *four* macros:

    	RDP0
    	WDP0
    	RDP1
    	WDP1

    where each of these either "R"eads or "W"rites DPTR #0 or #1, respectively, and a fifth one

    	TO_DPTR a

    that switches over to use of DPTR #0 or #1 depending on the argument passed.


    The tricky bit is to teach these macros which DPTR is the currently selected one, so they can generate

    	inc DPS
    or
    	dec DPS

    (or what ever your architecture uses to select one DPTR) if and only if they're needed. You'ld need a status variable to control this, and make sure you have a TO_DPTR after every entry point callable from the outside.

    In my experience, this is typically not worth the effort --- just write a comment explaining which DPTR you're actually referring to in a given instruction, and religiously use the distinction between inc DPS and dec DPS to indicate which direction a DPS change is meant to take.

Children