Beginner question on assembly (for the SX28)

Status
Not open for further replies.

Slimicus

New Member
Hello All,

Is there a way to pass a reference around to a particular PIN in assembly for the SX microcontroller?

I know I can declare a variable such as

Code:
LED_a    equ     RA.0
LED_b    equ     RA.1

But I want to be able to use generic variables such as

Code:
_param1      ds     1

to be able to pass "LED_a" to a subroutine using the call command. I'm pretty new at this, so there may be an entirely different method of doing this that I'm unaware of, but what I would LIKE to do is something similar to the following:


Code:
SetLedOutput 
            cje     _param1,#0,color_0
            cje     _param1,#20,color_1
            cje     _param1,#50,color_2
            cje     _param1,#254,color_3
            ret
color_0
            clrb  _param2 ;Hopefully _param2 contains a pin reference
            ret
color_1
            'some pwm code and conditional
            setb _param2
            ret
color_2
            'some pwm code and conditional
            setb _param2
            ret
color_3
            'some pwm code and conditional
            setb _param2
            ret


Then in my main program use it like this:

Code:
Main
            mov  _param2,LED_a
            mov  _param1,COLOR1
            call   SetLedOutput

            mov  _param2,LED_b
            mov  _param1,COLOR2
            call   SetLedOutput

Now, I'm not sure if this is even the proper way to attempt subroutines, as I said I'm still learning... but from what I read so far, I couldn't see a way to pass "parameters" to a subroutine directly, and if I use a macro, it will simply replicate that subroutine many times which could be costly in terms of program storage space... is there a better way to call subroutines with parameters?

Also the above code doesn't seem to work since I can't seem to move LED_a or LED_b into _param2, is there a way to accomplish this? Any help would be greatly appreciated
 
Is...

I'm sorry... please clarify what is SX microcontroller...

i've never seen such a kind of micro...

made by which co..?

Regards,

Simran..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…