NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Olsonist on April 14, 2015, 06:24:35 PM

Title: Non power of two code alignment
Post by: Olsonist on April 14, 2015, 06:24:35 PM
I have a 2K block of code. I'm adding code at the beginning and aligning addresses to 16 byte boundaries. That much is standard.

However I'd like to have one 16 byte block at the end, the last 16 bytes.
Any clean trick come to mind?
Title: Re: Non power of two code alignment
Post by: encryptor256 on April 14, 2015, 07:00:42 PM
Labeled block at the end of code or data:

At the end write:

Code: [Select]
myblock: times 512 db 0

Or

Code: [Select]
align 16
myblock: times 512 db 0
Title: Re: Non power of two code alignment
Post by: Olsonist on April 14, 2015, 08:05:43 PM
So that requires me to manually figure out how many bytes to skip and that's pretty much what I thought I'd have to do. Is it possible to ASSERT that I've done everything correctly? So if I add some instructions to the head of the 2k that the assembler would barf an error saying I'd forgotten the tail end.