Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 28th September 2007, 04:44 AM   (permalink)
Default Beginner question on assembly (for the SX28)

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
Slimicus is offline  
Old 28th September 2007, 07:44 AM   (permalink)
Smile 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..
__________________
Simran..
8051 Specialist..
simrantogether is offline  
Old 28th September 2007, 12:58 PM   (permalink)
Default

Quote:
Originally Posted by simrantogether
I'm sorry... please clarify what is SX microcontroller...

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

made by which co..?

Regards,

Simran..
It's the SX28 made by Parallax, Inc

http://www.parallax.com/detail.asp?p...id=SX28AC/DP-G
Slimicus is offline  
Old 28th September 2007, 02:59 PM   (permalink)
Default

I've not used the Parallax assembler for over a year now, but they have some good tutorials for it on the tech-tools site http://www.tech-tools.com/
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
AT89C4051 assembly code compiler question fiveten Micro Controllers 5 26th March 2006 07:37 PM
Converting S-Video to Composite: Beginner schematic question chson General Electronics Chat 2 29th June 2005 02:49 PM
serial assembly question evandude Micro Controllers 5 8th September 2004 06:37 AM
Assembly Language Question Jeggyman General Electronics Chat 6 30th January 2004 10:54 PM
Beginner question with a twist Somnambulo General Electronics Chat 4 20th July 2003 04:24 PM



All times are GMT. The time now is 06:41 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker