Align 256 in Pasmo?

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
cmal
Manic Miner
Posts: 635
Joined: Fri Jun 05, 2020 1:05 am
Location: California

Align 256 in Pasmo?

Post by cmal »

Is there a way to get the Pasmo assembler to align with a 256 byte memory location boundary? The align directive doesn't seem to work and the documentation does not list Align as an assembler directive.
User avatar
PROSM
Manic Miner
Posts: 481
Joined: Fri Nov 17, 2017 7:18 pm
Location: Sunderland, England
Contact:

Re: Align 256 in Pasmo?

Post by PROSM »

Here's a quick bodge I use for page alignment in Pasmo:

Code: Select all

if ($%256 != 0)
	org (($/256)*256)+256				; Align to a 256 byte page boundary
endif
EDIT: Removed extraneous brackets
All software to-date
Working on something, as always.
User avatar
cmal
Manic Miner
Posts: 635
Joined: Fri Jun 05, 2020 1:05 am
Location: California

Re: Align 256 in Pasmo?

Post by cmal »

PROSM wrote: Wed Aug 26, 2020 11:19 pm Here's a quick bodge I use for page alignment in Pasmo:

Code: Select all

if ($%256 != 0)
	org (($/256)*256)+256				; Align to a 256 byte page boundary
endif
EDIT: Removed extraneous brackets
Holy smokes! Thanks for that. I'll give it a try.
User avatar
bobs
Microbot
Posts: 107
Joined: Thu Dec 28, 2017 8:26 am
Location: UK
Contact:

Re: Align 256 in Pasmo?

Post by bobs »

I use something very similar to that, but use DEFS instead of ORG to allocate the required space to align the next instruction.

I also find it useful to store a label of that ‘padding’ size in case it’s large enough to store some data in. That also helps when re-arranging code to reduce such unused space.
Alone Coder
Manic Miner
Posts: 401
Joined: Fri Jan 03, 2020 10:00 am

Re: Align 256 in Pasmo?

Post by Alone Coder »

Maybe defs (-$)&255 will work, if Pasmo allows defs 0.
User avatar
ketmar
Manic Miner
Posts: 742
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: Align 256 in Pasmo?

Post by ketmar »

Code: Select all

org ($+255)/256*256
oneliner too, but doesn't involve possible UB with negative numbers bitops (it is unlikely that any Speccy asm is affected, but...)

p.s.: or without mul/div. ;-)

Code: Select all

org ($+255)&0xff00
User avatar
cmal
Manic Miner
Posts: 635
Joined: Fri Jun 05, 2020 1:05 am
Location: California

Re: Align 256 in Pasmo?

Post by cmal »

PROSM's suggestion worked - Thanks! I like bobs idea of using a label to keep track of the unused space so that it can be used for something later. Will give that a try.
Thanks for the other suggestions!
Post Reply