Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Can subroutines be located outside of the 'End' statement

Status
Not open for further replies.

Flamer1

New Member
Can subroutines be located outside of the last 'End' statement in a
program? Here is an example of a subroutine DATAIO defined outside
of the end statement

TRISB = 0

START:
PORTB.1 = 1
Pause 100
Goto DATAIO

PORTB.0
Pause 100
Goto START
End

DATAIO:
Serout PORTB.1, 4, ["Hello World!"]
Pause 100
Return
 
i'm writing a program right now that will be a large program once it's done. as it is, it's looking pretty sloppy with a bunch of Goto statements scattered across the program. i'd like to make it more readable by including the subroutines at the end, if possible
 
or put your sub-routines at the begining???
like.....


goto mainbody

;********sub1********
bsf porta,0
return
;********sub2********
bsf porta,1
return
;********main body*****
mainbody

I will appologise for the lack of imagination with the code :roll:
 
or create a file and then you include it. SO that it looks neat and if another program is able to use them as well you don't have to re-write the code, but use the include comand.

Ivancho
 
Jep use a project and then include all the files. can them *.inc but rember that if you include a file it become at that place in your asm FILE so hold that in mind.

And use CALL for a subroutine and not a GOTO. Because a CALL gif you a stack all the time so you can use it all the time.

Cya
 
It looks like he is using Pic Basic, so he couldn't easily use a CALL instruction or deal with .asm include files.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top