www.retrosoftware.co.uk
http://www.retrosoftware.co.uk/forum/

Assembling two routines together
http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=495
Page 1 of 1

Author:  Samwise [ Wed Aug 04, 2010 10:44 pm ]
Post subject:  Assembling two routines together

Newbie question #31020.

So, I can use this FOR syntax to do two-pass assembly:

Code:
FOR pass=0 TO 2 STEP 2
P%=&1900
[OPT pass
LDA &0
JMP later
LDA &1B
RTS
BRK
.later
LDY #0
RTS
]
NEXT

and pick up labels which are later in the routine.

Now, suppose I want to assemble a second, different routine at a different location in memory.

Code:
FOR pass=0 TO 2 STEP 2
P%=&2400
[OPT pass
LDA &0
JMP laterroutine2
LDA &1B
RTS
BRK
.laterroutine2
LDY #0
RTS
]
NEXT

Is there anyway of compiling the two together so that you can use labels in the first routine which are actually pointing to the second routine? e.g. in the above examples, so you could use the label .laterroutine2 in the first routine which is stored at &1900.

Or if that's not possible I assume the only option in this case would be to resort to manually recording .laterroutine2's memory location and storing that in a variable in routine 1?

Not urgent, but I'm curious as to the answer ...

Sam.

Author:  RichTW [ Thu Aug 05, 2010 8:18 am ]
Post subject:  Re: Assembling two routines together

Code:
FOR pass=0 TO 2 STEP 2
P%=firstaddr
[OPT pass
....
]
P%=secondaddr
[OPT pass
....
]
NEXT

Simple as that! :)

Author:  Samwise [ Thu Aug 05, 2010 9:19 am ]
Post subject:  Re: Assembling two routines together

ahh ... two sets of square brackets. That's the bit I was missing. Obvious when I look at it, now. :)

Thanks again, Rich!

Sam.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/