This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

ASM6 include files relative to folder

ASM6 include files relative to folder
by on (#172423)
Mind if i sneak in a newbie question on asm6? I don't feel it's justified to start a whole new topic on such a small question.

When i incbin stuff, and the adress is relative, asm6 puts it relative to itself rather than the folder of the source. Is this normal? Can i change it without specifying absolute?
Re: Recommended assembler for NES development beginner [POLL
by on (#172427)
WheelInventor wrote:
Mind if i sneak in a newbie question on asm6? I don't feel it's justified to start a whole new topic on such a small question.

When i incbin stuff, and the adress is relative, asm6 puts it relative to itself rather than the folder of the source. Is this normal? Can i change it without specifying absolute?

No, this type of question warrants a separate thread. Tepples, could you please split this off and make it its own thread?

"Folder of the source" doesn't make any sense -- can you explain what you mean by that? Pathnames/filenames don't control anything. So yes, it's going to be relative to whatever PC is at the time incbin is used. This is universal across all assemblers. What exactly are you trying to do? If you really need to set an absolute address of something, use $ or BASE (please go back and read readme.txt that comes with asm6! :-) ).
Re: ASM6 include files relative to folder
by on (#172429)
I think OP is talking about where it fetches the included file from, koitsu.

Perhaps you can work around the problem by running the assembler from the same folder as the source files (i.e. use a relative path to execute asm6).

Also, given the nature of the two thing being confused here, might be worth pointing out that when koitsu said "PC" he meant "program counter" (the assembled location of code in the output ROM) and not "personal computer" (the place where your files are stored).


So I guess ASM6 uses the working directory for include paths, rather that the directory containing the file being assembled (like any C compiler must, and cc65/ca65 does)? I generally assemble stuff with a batch file that runs from the directory of the source, so I don't think I would have noticed either way. (Edit: tepples says below ca65's incbins are working-directory relative? Weird.) (Edit again: not exactly, incbin will look for both but it check's the working directory first.)
Re: ASM6 include files relative to folder
by on (#172431)
This is my setup:
asm6 is lazily put in c:\
project is in C:\Users\E\Documents\NESDEV\project
project.asm is in this folder, so i'll write asm6 C:\Users\E\Documents\NESDEV\project\project.asm [testfile01] in the command line

my assumption was that any binary included (like so: "BIN patterns.chr") would treat this relative to the path of project.asm, but expects me to put any incbins in the same folder as asm6.exe, that is, c:\ in this example.

also, sorry for mixing paths and adresses in the previous post. :oops:
Re: ASM6 include files relative to folder
by on (#172432)
Ninja'd twice. Let me restate the question:

In README.txt in the asm6 distribution, loopy wrote:
INCLUDE (also INCSRC)

Assemble another source file as if it were part of the current source.

Code:
INCLUDE whatever.asm


But from what folder does ASM6 try to read whatever.asm? Say I have this setup:
Code:
~/develop/corral$ ls src
main.s
nes.inc
[other files omitted]
~/develop/corral$ asm6 -l src/main.s corral.nes

Or on Windows:
Code:
C:\Users\pino\develop\corral>dir /b src
main.s
nes.inc
[other files omitted]
C:\Users\pino\develop\corral>asm6 -l src\main.s corral.nes


Which line should appear in src/main.s?
Code:
; This works if paths are relative to the current working directory (CWD)
include src/nes.inc

; This works if paths are relative to the directory of the including file
include nes.inc


End of restated question.

I haven't used ASM6, but the definition of include() starting at line 1633 implies that paths of included files are CWD-relative. To work around this, you'll want to put your batch file that calls asm6 in the same folder, as Windows sets the CWD to the folder containing the batch file. If the folder containing asm6.exe is not on your Path, you'll want to put the full path to asm6.exe in your batch file that calls asm6.

Digression for those following multiple assemblers:

The last version of ca65 on cc65.org (2.12 or thereabouts) treated paths referenced in .include as relative to the CWD. Around the time cc65 moved to GitHub and adopted the permanent version number 2.14, three breaking changes were committed. One was ca65 treating paths as relative to the directory of the including file, not the CWD. (The others were ca65 not accepting negative byte values without < or .feature force_range and ld65 requiring the output file to appear before source files on the command line.) The .incbin statement in ca65 still appears to operate relative to the CWD.
Re: ASM6 include files relative to folder
by on (#172433)
WheelInventor wrote:
put any incbins in the same folder as asm6.exe

I'm pretty sure it's not "the same folder as asm6.exe", it's just your working directory.

If you run it from C:\Users\E\Documents\NESDEV\project, your working directory would be there.

C:\Users\E\Documents\NESDEV\project> C:\asm6.exe progect.asm
or
C:\Users\E\Documents\NESDEV\project> ..\..\..\..\..\asm6.exe progect.asm
for example.
Re: ASM6 include files relative to folder
by on (#172436)
rainwarrior wrote:
C:\Users\E\Documents\NESDEV\project> C:\asm6.exe progect.asm
or
C:\Users\E\Documents\NESDEV\project> ..\..\..\..\..\asm6.exe progect.asm
for example.

Yes, this is how I call ASM6.
Re: ASM6 include files relative to folder
by on (#172438)
tokumaru wrote:
rainwarrior wrote:
C:\Users\E\Documents\NESDEV\project> C:\asm6.exe progect.asm
or
C:\Users\E\Documents\NESDEV\project> ..\..\..\..\..\asm6.exe progect.asm
for example.

Yes, this is how I call ASM6.


Thanks, this must be it! Though, when i try doing it like this, win8 throws me an access denied. Off to google i go. :roll:
Re: ASM6 include files relative to folder
by on (#172439)
His use of the word "adress" (sic) is what induced confusion.

Yes, the incsrc/incbin paths are based off of the current working directory. If they're in an alternate path, it should be possible to specify the full path in the incsrc/incbin line. However: I do not know if pathnames with spaces work correctly (haven't tested).

Changing the current working directory by making a batch file that changes to whatever directory is needed (by switching drive letter and using cd, or using cd /D to do both together at once), then referencing the assembler via full path (e.x. C:\asm6.exe). A lot of people call this a "build batch file", common names include build.bat or make.bat. rainwarrior covered all this though, huzzah. Example:

Code:
@echo off
cd /D C:\Users\E\Documents\NESDev\project
C:\asm6.exe progect.asm
Re: ASM6 include files relative to folder
by on (#172440)
WheelInventor wrote:
Though, when i try doing it like this, win8 throws me an access denied. Off to google i go. :roll:

LOL sounds like it's time to get it out of the root directory. :P

Personally I keep a copy of the assembler I'm using for any given project in a subdirectory of that project. The assemblers have so many versions, and poor backwards compatibility, and they're small enough that it doesn't make much sense to me to try and share them in a common folder like that (I especially wouldn't use environment variables like PATH etc., locking the whole system to one version of the assembler).
Re: ASM6 include files relative to folder
by on (#172446)
tepples wrote:
The last version of ca65 on cc65.org (2.12 or thereabouts) treated paths referenced in .include as relative to the CWD. Around the time cc65 moved to GitHub and adopted the permanent version number 2.14, three breaking changes were committed. One was ca65 treating paths as relative to the directory of the including file, not the CWD. (The others were ca65 not accepting negative byte values without < or .feature force_range and ld65 requiring the output file to appear before source files on the command line.) The .incbin statement in ca65 still appears to operate relative to the CWD.

After a little testing of ca65:

.include searches only relative to the source path.

.incbin searches relative to the working directory, then falls back to relative to the source path.
Re: ASM6 include files relative to folder
by on (#172519)
Hehe yeah, it seems the way i did it successfully before has become a case of access denied, too. i guess somewhat current versions of win doesn't like activity in the root. :roll: Keeping a copy in every project folder is a very neat idea. I'll do that! Thanks again.

This thread is solved as far as i'm concerned. :beer: