It is currently Wed Dec 13, 2017 8:08 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu Jun 02, 2016 8:17 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1124
Location: Gothenburg, Sweden
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?

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 9:14 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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! :-) ).


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 9:42 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5893
Location: Canada
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.)


Last edited by rainwarrior on Thu Jun 02, 2016 10:57 am, edited 4 times in total.

Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 9:48 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1124
Location: Gothenburg, Sweden
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:

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 9:50 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19338
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 9:52 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5893
Location: Canada
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.


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 10:02 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 10:08 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1124
Location: Gothenburg, Sweden
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:

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 10:10 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 10:12 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5893
Location: Canada
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).


Top
 Profile  
 
PostPosted: Thu Jun 02, 2016 11:00 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5893
Location: Canada
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.


Top
 Profile  
 
PostPosted: Fri Jun 03, 2016 12:01 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1124
Location: Gothenburg, Sweden
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:

_________________
http://www.frankengraphics.com - personal NES blog


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 11 guests


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