Jump to content
IGNORED

Doing page alignment in AMAC?


Recommended Posts

The IBM S/370 Assembler I used to use on mainframes has an ALIGN directive (generally you'd want to align on 2, 4, 8 byte boundaries for convenience of constant storage).

 

With our common Assemblers it'd be like:

 

AsmEd:  *=*+$FF&$FF00

 

Mac-65:  .ORG *+$FF&$FF00

(and can also use the AsmEd method)

 

For different alignments just use the relevant add and mask values, e.g. 7 and $FFF8 for 8 byte alignment, $3FF and $FC00 for 1K alignment.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

I was just messing with that in a game I had where I wanted the customer character set to be on a page boundary and display lists to not cross one.

 

In my old code, I did this:

 

     ORG $3000-$3

     jmp Init

 

< define the character set here, where it will end up at 0x3000>

<define the display lists here, where they will end up at 0x3400>

 

Init:

     ; this is where the real code starts

 

...

 

end Init (sets the run address to Init)

 

Link to comment
Share on other sites

My today approach is to just start the code off with the character set first, and set the run address via the XEX format.

 

Then if compiling with ca65, don't set the start address there, but set it at the link stage, and just make sure it starts on a page boundary.

 

I have some .ASSERT directives in the source to generate an error in case I forget.

 

You can also use the .ALIGN directive of ca65.

 

Link to comment
Share on other sites

Here is the ca65 source fragment for above, with the .ALIGN directive commented out, since I prefer doing it at the link stage...

 

; ----------------------------------------
; Character Sets and Display Lists
; ----------------------------------------

; Chset and DL's don't like to cross page boundarys...
;		.ALIGN	$100
		.ASSERT (* .MOD $100) = 0, error, "Character set not page aligned"

; Include the custom character set
		.INCLUDE "chset.a65"

; Double check all bytes are there...
		.ASSERT * = (ChSet1+$400), error, "Character set incorrect size"

; We include the Display List data next, to stay on/prevent crossing a page boundary
		.INCLUDE "mdldata.a65"

 

Link to comment
Share on other sites

And the original code (1984) for AMAC:

 

* Chset and DL's don't like to cross
* page boundarys...

		ORG $3000-3
Start:	jmp Init

		INCLUDE D:CHSET.MAC

* Double check...
		ASSERT	*L=[ChSet1+$400]

		INCLUDE D:MDLDATA.MAC

Init:
		Stz Hscore
		sta Hscore+1
		ldx #4			;read ego
		ldy #CBGET		;count.. er..
		jsr DiskHi		;I mean hscore
.
.
.
		END Start

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...