Jump to content
Andrew Davie

Session 9: 6502 and DASM - Assembling the Basics

Recommended Posts

Yeah the .bin extensions are binary files. An .asm file is just a plain old text document with a different extension name, so you know it is for assembly. The compiler doesn't care about the extension name, it just has to know what value to give all those labels in the file.

 

Make sure you have a copy of the vcs.h and macro.h file in the same folder as DASM along with your .asm file.

Share this post


Link to post
Share on other sites

I don't know what I'm doing wrong here. I can't get the sample kernel1.asm to compile/assemble. (btw there is no .asm in the attachment - only a .bin so I pasted the code into an editor..

 

I get an error message for each and every mnemonic ... help!

 

---------- compile ----------

 

START OF PASS: 1

kernel1.asm (2): error: Unknown Mnemonic '6502'.

kernel1.asm (26): error: Unknown Mnemonic 'lda'.

kernel1.asm (28): error: Unknown Mnemonic 'sta'.

kernel1.asm (32): error: Unknown Mnemonic 'lda'.

kernel1.asm (34): error: Unknown Mnemonic 'sta'.

kernel1.asm (42): error: Unknown Mnemonic 'sta'.

kernel1.asm (44): error: Unknown Mnemonic 'sta'.

 

..... and so on.

 

 

EDIT Sorry - found out instructions need to be indented..... move on - nothing to see here.

Edited by davyK

Share this post


Link to post
Share on other sites
I don't know what I'm doing wrong here. I can't get the sample kernel1.asm to compile/assemble. (btw there is no .asm in the attachment - only a .bin so I pasted the code into an editor..

 

I get an error message for each and every mnemonic ... help!

 

---------- compile ----------

 

START OF PASS: 1

kernel1.asm (2): error: Unknown Mnemonic '6502'.

kernel1.asm (26): error: Unknown Mnemonic 'lda'.

kernel1.asm (28): error: Unknown Mnemonic 'sta'.

kernel1.asm (32): error: Unknown Mnemonic 'lda'.

kernel1.asm (34): error: Unknown Mnemonic 'sta'.

kernel1.asm (42): error: Unknown Mnemonic 'sta'.

kernel1.asm (44): error: Unknown Mnemonic 'sta'.

 

..... and so on.

 

are your instructions indented?

 

this will not work:

 

processor 6502
include "vcs.h"
include "macro.h"
org $F000
START
lda #$82
sta VBLANK
sta VSYNC

; Ect...

 

but this will:

 

		  
  processor 6502
  include "vcs.h"
  include "macro.h"
  org $F000
START
  lda #$82
  sta VBLANK
  sta VSYNC

; Ect...

 

all instructions must be indented and labels must be all the way to the left.

 

also, you may want to zip the .asm file so you can upload it :)

Edited by Wickeycolumbus

Share this post


Link to post
Share on other sites

A note for future newbies who might be tempted to skip steps:

The other switches "-f3" and "-v5" control some internals of DASM - and for now just assume you need these whenever you assemble with DASM.

I'm going through these tutorials now, and was having problems assembling this kernel until I reread this line. If the assembler seems to work, but the .bins you create are garbage, this may well be why! :dunce: If you omit these switches, the assembler doesn't complain, but in my case, I got a .bin that emitted a high-pitched tone and did nothing else. Oops.

Edited by thegoldenband

Share this post


Link to post
Share on other sites
A note for future newbies who might be tempted to skip steps:
The other switches "-f3" and "-v5" control some internals of DASM - and for now just assume you need these whenever you assemble with DASM.

I'm going through these tutorials now, and was having problems assembling this kernel until I reread this line. If the assembler seems to work, but the .bins you create are garbage, this may well be why! :dunce: If you omit these switches, the assembler doesn't complain, but in my case, I got a .bin that emitted a high-pitched tone and did nothing else. Oops.

I don't think you need to worry about the -v5 switch ("-v" is for "verbosity")... but you absolutely, positively need the -f3 switch, or the .BIN won't be in the correct format ("-f" is for "format"). Well, I did find the -f2 format to be useful when I was customizing batari Basic to create MNetwork bankswitched ROMs, but I had to write a utility to convert the output to the proper format-- and even though I didn't realize it back then, I have since learned that there's a much, *much* easier way to do what I was trying to do (by using ORG and RORG to define the different banks), and still be able to use -f3.

 

Michael

Share this post


Link to post
Share on other sites
I don't think you need to worry about the -v5 switch ("-v" is for "verbosity")... but you absolutely, positively need the -f3 switch, or the .BIN won't be in the correct format ("-f" is for "format").

Thanks for that clarification! That makes a lot of sense.

 

Meanwhile, I'm having a fun time using this code for a purpose wholly different than what it was intended for, i.e. throwing things at the sound registers at various points in the kernel and seeing what results I get! It seems like if you're mainly interested in sound design and manipulating the sound hardware (as I am), you can dive into this stuff surprisingly quickly.

Share this post


Link to post
Share on other sites

Late to the party by a decade or so, but:  I'm noticing that most of the dasm zip files, including the linked one, do not come with the includes.  I had to hunt for the batari basic package to find 'em.

Share this post


Link to post
Share on other sites
35 minutes ago, SavedByZero said:

Late to the party by a decade or so, but:  I'm noticing that most of the dasm zip files, including the linked one, do not come with the includes.  I had to hunt for the batari basic package to find 'em.


That is one source, but the best place to get dasm these days, including the includes, is at...
https://dasm-assembler.github.io/

 

  • Like 2

Share this post


Link to post
Share on other sites

I will say I'm finding "Atari 2600 programming for newbies" wayyyyy easier to understand, so far, than "Making Games For the Atari 2600" book for kindle.  This is not to slight Huggins' book, but I feel like that's much more of an intermediate level book that I might read again after I finish the newbies tutorials.

  • Like 1

Share this post


Link to post
Share on other sites

It works! Using Windows 10 with dasm 2.20-11 and z26_407.

-The include file needs the path from dasm to the atari header files. Currently that is #include "Atari-2600\vcs.h" (for example).

 

Thank you so much.

 

-Grant

 

Share this post


Link to post
Share on other sites
On 11/24/2019 at 12:38 PM, Grant said:

It works! Using Windows 10 with dasm 2.20-11 and z26_407.

-The include file needs the path from dasm to the atari header files. Currently that is #include "Atari-2600\vcs.h" (for example).

 

Thank you so much.

 

-Grant

 

 

It is usual/common to to copy those files to the directory with your code.

 

Share this post


Link to post
Share on other sites
On 11/23/2019 at 8:38 PM, Grant said:

It works! Using Windows 10 with dasm 2.20-11 and z26_407.

-The include file needs the path from dasm to the atari header files. Currently that is #include "Atari-2600\vcs.h" (for example).

 

Thank you so much.

 

-Grant

 

Other options include A) adding an incdir instruction before your includes to specify the directory all your include files are in, or B) specifying the include directory at compile-time using the -I option.


But yeah, it's probably easier to just copy the files over. They're small. 🙂

Share this post


Link to post
Share on other sites

i am having trouble running this code. so i run this on an emulator? where do i put the 

dasm kernel.asm -lkernel.txt -f3 -v5 -okernel.bin

is this a separate file i make?

 

Edited by sparkplug.0128

Share this post


Link to post
Share on other sites
8 hours ago, sparkplug.0128 said:

i am having trouble running this code. so i run this on an emulator? where do i put the 

dasm kernel.asm -lkernel.txt -f3 -v5 -okernel.bin

is this a separate file i make?

 

 

dasm is a command line program.  If you're on Windows you'll run it via the Command Prompt (dos window), if on Mac you'll run it via a Terminal session.  If you're on Linux you'll also use a terminal session, though how you launch it depends upon your particular distribution.

 

 

Share this post


Link to post
Share on other sites
11 hours ago, SpiceWare said:

 

dasm is a command line program.  If you're on Windows you'll run it via the Command Prompt (dos window), if on Mac you'll run it via a Terminal session.  If you're on Linux you'll also use a terminal session, though how you launch it depends upon your particular distribution.

 

 

this is the output i get:

image.png.cbc8075b6ef62b1d421398f210918f8c.png

 

i tried running as an administrator and it was the same output

Edited by sparkplug.0128

Share this post


Link to post
Share on other sites
4 minutes ago, sparkplug.0128 said:

update: i think i got something?

 

easiest to get started is to create a new directory(folder) for your project, such as c:\atari\project1 

 

Then you'd do this:

  1. Use file explorer and put dasm.exe and kernel.asm into c:\atari\project1
  2. start the Command Prompt
  3. type cd c:\atari\project1
  4. type dasm kernel.asm -lkernel.txt -f3 -v5 -okernel.bin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...