EASy68K  
It is currently Wed Sep 19, 2018 12:27 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Local labels
PostPosted: Thu Dec 08, 2011 2:21 pm 
Offline

Joined: Fri Dec 02, 2011 10:57 am
Posts: 11
I am not sure if this is the approppriate place for this question. It is neither about the simulator nor about the 68000 but about the assembler.

So, the question is simple: is it possible to define local labels in my code?

I'm familiar with some Z80 assemblers that allow local label definition, such as:

Code:
LABEL1: some code
.LOOP: do something
  branch to .LOOP

LABEL2: some more code
.LOOP do some more things
  branch to .LOOP


and, when assembling, the .LOOP are expanded to LABEL1.LOOP and LABEL2.LOOP. So, they are somehow local to the last global label.

Also, some other assemblers allow defining MODULES so that all labels defined inside that module are local to it.

Is there something similar with easy68k?

Finally, I was wondering if there is some way to create a rellocatable binary so that, for example, I can give the binary to my students and they just have to include it as a binary without having access to the source code.

Thanks very much! And congratulations for this very nice simulator!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2011 6:32 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
You can get local labels within macros by using a trailing '\@'.

Generally you could use high level constructs like repeat/until or if/else/endif to limit the need for labels.

For libraries :

You could paste in S-Records to bring in pre-built code, with predefined entry points, like a ROM. Or you could drop in opcode streams into the source using DC.W

You could use INCBIN to pull in external binary code, of INCLUDE for external source code.

It's also possible to use external tool chains to build and link libraries, and run the S-Records they generate. This however is somewhat clumsy.

IDE68K supports more of a compiler/linker model, and has libraries. These libraries however only slightly obfuscate the source. It also supports include files.

Actually showing the source is probably a good way of learning how to do things.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2011 8:00 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1080
Local labels are supported anywhere in a program.

From EASy68K Help/ Quick Start

Local labels may be reused in a program. Local labels must start with a dot '.' and be followed by letters, numbers or underscores. Global labels define the boundaries of a local label. When a local label is defined it may only be referenced from code above or below the local label until the next global label is encountered. The assembler creates a unique name for local labels by appending the local label name to the preceding global label and replacing the dot with a colon ':'. Only the first 32 characters of the resulting name are significant.

Use INCBIN directive to include binary files.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Local labels
PostPosted: Fri Dec 09, 2011 6:20 pm 
Offline

Joined: Fri Dec 02, 2011 10:57 am
Posts: 11
Thanks for your replies. Profkelly, my apologies for asking something which is in the docs. I should apply a RTFM to myself ;-)

Regarding the INCBIN, my question was more related to what clive said. I was interested on including a binary file containing relocable 68000 code. I mean, something like:

ORG START_ADDRESS
INCBIN "mylibrary.bin", START_ADDRESS

So that all references to memory inside the binary will be relative to START_ADDRESS. Of course, I can do it myself avoiding absolute references in my code, or using some of the techniques proposed by Clive.

So, the problem is solved. Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group