It is currently Wed May 24, 2017 4:31 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Syntax Error: .ORG $7FF0
PostPosted: Tue May 16, 2017 9:38 pm 
Offline
User avatar

Joined: Tue May 16, 2017 9:25 pm
Posts: 4
So, I just began to program for the NES and am currently using xa65 on Raspberry Pi. My trouble, however, begins during assembly. Before I added the header, everything assemble just fine. But the newly generated file won't run in FCEUX, so I added the discount header seen in the source. Now, whenever I attempt to assemble my code it shoots me the following error :

Code:
  .ORG $7FF0
Desktop/nes.s:line 1: 1000:Syntax error
  .org $8000
Desktop/nes.s:line 19: 1012:Syntax error
Break after 2 errors


The source code I am starting out with comes from the tutorial page:

Code:
  .ORG $7FF0
header:
  .db "NES", $1a
  .db $00
  .db $00
  .db $02
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00
  .db $00

  .org $8000
reset:
  lda #$01   ; square 1
  sta $4015
  lda #$08   ; period low
  sta $4002
  lda #$02   ; period high
  sta $4003
  lda #$bf   ; volume
  sta $4000
forever:
  jmp forever


Top
 Profile  
 
PostPosted: Tue May 16, 2017 9:44 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 137
Location: Central Illinois, USA
Looking at the man page for xa65, it looks like it doesn't support the .org pseudo-op. You'll have to read the manual to figure out how to get your code to be located at a certain point. The .org pseudo-op tells the assembler where (at what memory address) to locate the next block of code. Different assemblers have different semantics for doing that, so a tutorial that works for one assembler won't work for another out of the box. (There's quite a bit of difference in 6502 assembly syntax, unlike some other languages that are more standardized.)

So you'll either have to study the manual for your assembler, or switch to a different assembler that better matches the tutorial code :-/

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Tue May 16, 2017 10:03 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9645
Location: Rio de Janeiro - Brazil
It looks like xa65 doesn't have a direct replacement for .ORG, but you can change the value if the PC like this: * = $XXXX

Changing the PC afterwards won't cause any padding though, like .ORG would. Instead, you have to do the padding yourself, like this: .dsb $XXXX - *


Top
 Profile  
 
PostPosted: Tue May 16, 2017 10:44 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 5682
Location: Seattle
I wrote a bunch of trivial NES ROMs using XA65; debian even includes one (i.e. "apt-get source efp" - this is not mine)


Top
 Profile  
 
PostPosted: Wed May 17, 2017 12:43 am 
Offline
User avatar

Joined: Sat Jul 12, 2014 3:04 pm
Posts: 792
tokumaru wrote:
It looks like xa65 doesn't have a direct replacement for .ORG, but you can change the value if the PC like this: * = $XXXX

Changing the PC afterwards won't cause any padding though, like .ORG would. Instead, you have to do the padding yourself, like this: .dsb $XXXX - *
Does .dsb with 0 bytewidth throw an error?


Top
 Profile  
 
PostPosted: Wed May 17, 2017 7:04 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9645
Location: Rio de Janeiro - Brazil
I have no idea, but if you run into a case where you need a bytewidth of 0, just don't use the command at all.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 7:20 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18338
Location: NE Indiana, USA (NTSC)
Automating the decision to use or not use the command, depending on the size of preceding data, would look like the following (pseudocode, untested):

Code:
.if * < $XXXX
  .dsb $XXXX - *
.endif


Not having studied xa65's error reporting commands, I don't know how to ensure failure if preceding data is too large. In ca65, one might use .assert.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 9:59 am 
Offline
User avatar

Joined: Tue May 16, 2017 9:25 pm
Posts: 4
lidnariq wrote:
I wrote a bunch of trivial NES ROMs using XA65; debian even includes one (i.e. "apt-get source efp" - this is not mine)


That's very helpful, actually. That way I can see the proper pseudo-Ops. If only I wasn't at work, I am itching to check it out.

gauauu wrote:
Looking at the man page for xa65, it looks like it doesn't support the .org pseudo-op. You'll have to read the manual to figure out how to get your code to be located at a certain point. The .org pseudo-op tells the assembler where (at what memory address) to locate the next block of code. Different assemblers have different semantics for doing that, so a tutorial that works for one assembler won't work for another out of the box. (There's quite a bit of difference in 6502 assembly syntax, unlike some other languages that are more standardized.)

So you'll either have to study the manual for your assembler, or switch to a different assembler that better matches the tutorial code :-/


Good thing I am still fairly green when it comes to programming anything. I don't have any bad habits as of yet that I've become particularly attached to. It's just getting to where I can at least make something rudimentary happen at all. Unfortunately, there isn't an armhf port of any other assembler available on the Raspbian repositories, and I'm not quite comfortable compiling source. That being said, given the limitations, I'll definitely study the XA65 man pages a bit more. Thank you guys for all the good advice. It makes this journey that much less intimidating.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 10:24 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18338
Location: NE Indiana, USA (NTSC)
opm_gamedev wrote:
I'm not quite comfortable compiling source.

I've tried to provide instructions here and here.

You mentioned using an operating system based on Debian. So do I. First install dependencies:
Code:
sudo apt-get install build-essential python3-pil git

build-essential is GCC, Binutils, Make, and other parts required for building C or C++ programs from source.
python3-pil is Pillow (Python Imaging Library), which lets a PNG-to-CHR converter written in Python read the PNG image files you pass to it.
git is a version control system, used (among other things) to download source code with its full revision history.

Then build and install cc65, and tell me the first thing you don't understand:
Code:
mkdir -p ~/develop
cd ~/develop
git clone https://github.com/cc65/cc65.git
cd cc65
make
make install prefix=~/.local
which cc65


Top
 Profile  
 
PostPosted: Fri May 19, 2017 9:24 am 
Offline
User avatar

Joined: Tue May 16, 2017 9:25 pm
Posts: 4
tepples wrote:
Then build and install cc65, and tell me the first thing you don't understand:

The first thing I don't understand at this point is: "where do I go from here?"
I entered the commands to execute both CC65 and CA65, with the CLI returning a message that neither command exists. Even after following the instructions to the letter.

I did take note as the CLI spit out file names during source compilation that among C files were a bunch of Assembler files. This caused concern. Even though I am running a Debian derivative, I am doing so on an ARMv8 CPU. So, if the source code I compiled was written for x86, I wouldn't be able to run the software. Hopefully, this is not the case. Especially, if CA65 is the more commonly used Assembler.


Top
 Profile  
 
PostPosted: Fri May 19, 2017 9:39 am 
Offline
User avatar

Joined: Tue May 16, 2017 9:25 pm
Posts: 4
tokumaru wrote:
It looks like xa65 doesn't have a direct replacement for .ORG, but you can change the value if the PC like this: * = $XXXX

Changing the PC afterwards won't cause any padding though, like .ORG would. Instead, you have to do the padding yourself, like this: .dsb $XXXX - *


Three Questions:
    1. So, I would write the code * = $XXXX exactly?
    2. How would I determine the proper padding size?
    3. Is this mandatory?


Top
 Profile  
 
PostPosted: Fri May 19, 2017 9:43 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18338
Location: NE Indiana, USA (NTSC)
Now that cc65 is built and installed, you need to set your PATH to include executables installed for the current user.

The .bashrc file is a shell script that Bash runs when it starts. Among other things, it's used to set up the PATH, the list of folders where the shell looks for programs to run. By default, the shell doesn't include any folder in your home directory in this list, so you'll need to add it.
Code:
mousepad ~/.bashrc

Put this at the bottom:
Code:
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Translated into English: "If a folder called .local/bin exists inside your home directory, add it to the PATH."

Then log out and back in, and make sure the change to the PATH took:
Code:
which cc65

The which command is a quick way to search the PATH without actually running anything.

Quote:
I did take note as the CLI spit out file names during source compilation that among C files were a bunch of Assembler files.

These are in 6502 assembly language, not x86, x86-64, or ARM assembly language. They make up part of the standard library that gets included in the executable when you build a program written in C.


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 3 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