6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:47 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Aug 21, 2024 11:35 am 
Offline

Joined: Wed Aug 21, 2024 11:33 am
Posts: 3
I was working on some other compiler and want to get a fresh breeth, so, I worked on that project.

It support basic syntax and some preprocessor directives. It can generate binary file (ROM) but not ELF or MBF format. You can use it for NES or Atari game development. I will be happy to get feedback and improve it make it usable by who interest on that.

https://github.com/erhanbaris/timu6502asm


Last edited by erhanbaris on Wed Aug 21, 2024 11:53 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 11:38 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Hello, and welcome! Well done, it's always good to see a software project which is useful to 6502 users.

I think perhaps it would be best to call this an assembler - even better if you could edit the subject of this thread. Otherwise we might have a pointless reply (or two) about the use of "compiler" versus "assembler" - which to me is obviously just a difference of dialect.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 11:53 am 
Offline

Joined: Wed Aug 21, 2024 11:33 am
Posts: 3
BigEd wrote:
Hello, and welcome! Well done, it's always good to see a software project which is useful to 6502 users.

I think perhaps it would be best to call this an assembler - even better if you could edit the subject of this thread. Otherwise we might have a pointless reply (or two) about the use of "compiler" versus "assembler" - which to me is obviously just a difference of dialect.


Done :)


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 11:56 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Great!

What we should really be doing is discussing the facilities your assembler offers - of course, I haven't had a good look.

Also notable, on this forum you'll find a number of unique self-built 6502 computer designs, as well as interest in the historical offerings from Commodore, Apple, Acorn, and others. We're quite well distributed over the various possible interests - including but not limited to the consoles.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 5:15 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
Welcome to 6502 land.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 5:26 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Oh, one thing I notice in your README, Erhan, is that you do offer local labels - a nice feature - but you call them 'branches'. I think everyone would say that a label is the place you get to, whereas a branch is the means of getting there.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 21, 2024 9:51 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
I'll second that.  A label is a target.  A branch is an action, as with all the conditional branch instructions BNE, BEQ, BPL, etc. (and the BRA Branch Relative Always instruction).  In the interest of source-code density, hopefully labels don't require being on their own line, but can instead be followed by code on the same line.

I suggest also changing the terminology also on variables.  What you have here:
Code:
  var1 = $10
  var2 = 22
  var3 = %11001100
suggests that variable 1 is stored at address $10 (which is in ZP RAM).  Otherwise, what you have there are constants, or equates, not variables.  Variables are scratchpad records the target computer can keep changing as needed.  Most assemblers will do something like (and I'll change your "var" to "con" for "contant"):
Code:
CON1:  EQU  $10
CON2:  EQU  22
CON3:  EQU  %11001100


Where you have:

Quote:
.word

Write 1 or many word information into memory


    .byte $1122
    .byte $3344, $5566
I suspect you meant to put ".word" there (in blue), not ".byte."

This may need some clarification:

Quote:
.org

Change reference locations. It is not changing where the codes are stored, it is changing jump and branch references.

because in my experience with assemblers, .org very much does change where the code is laid down.

I have a list of recommendations for if someone writes an assembler, at http://wilsonminesco.com/AssyDefense/as ... uests.html, linked on the Program Tips page of the 6502 Primer—although I see now it could stand some improvement.

In any case, writing an assembler is always a good learning experience.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 11:20 am 
Offline

Joined: Wed Aug 21, 2024 11:33 am
Posts: 3
I made a small mess in the README file. I'll make the necessary correction. Since English is not my first language, I occasionally make mistakes. I appreciate all of your feedback. I'll take care of those problems as soon as I can, and feel free to request any more features that you would really like to see or use. Since I wrote it in less than ten days, not many features are available at this time. If someone is interested in my project, I intend to dedicate more effort to improving it.
I will check all those links and try to change based on those informations.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 11:25 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Very impressive! Not to worry too much about your English - easily corrected!

I see you have a few minimal test files - it might be good also to have an example file which shows every feature. In particular, all of your directives.

One directive which might be useful is an alignment directive - for example to place something at the next page boundary.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 12:06 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 336
GARTHWILSON wrote:
in my experience with assemblers, .org very much does change where the code is laid down.

That's what every assembler I've used does, and it's almost always what you want.

But not always always. Occasionally there's a need for assembling code to one location with the intent that it be copied to another before it is run (such as CHRGET in Microsoft's BASIC). Do any assemblers provide a way to do that? It's not something that would be used often, but it would be a useful feature to have.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 5:32 pm 
Offline

Joined: Wed Jan 01, 2003 6:32 pm
Posts: 34
Most assemblers can do that. I most cases the .org statement defines the stert adress of the code, but not the location of the code in the source file. Thus, by careful .ORGing und referencing the code in question can be easily copied to its destined location in memory.

Dietrich

_________________
My system: Elektor Junior Computer, GitHub https://github.com/Dietrich-L


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 5:50 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
John West wrote:
GARTHWILSON wrote:
in my experience with assemblers, .org very much does change where the code is laid down.

That's what every assembler I've used does, and it's almost always what you want.

But not always always. Occasionally there's a need for assembling code to one location with the intent that it be copied to another before it is run (such as CHRGET in Microsoft's BASIC). Do any assemblers provide a way to do that? It's not something that would be used often, but it would be a useful feature to have.

A common trick seen with 6502-powered home computers from the late 1970s and early 1980s was loading a program into the stack, which would cause it to automatically run when loading was finished.  Obviously it wasn’t possible to assemble directly into the stack—the assembler would lose control of the machine, so the program was assembled for the stack address, but actually deposited elsewhere in RAM for saving to local mass storage.

The HCD-65 DEVPAK assembler for the Commodore 128 emitted an object file in MOS Technology portable format (similar to an S-record file), rather than an actual binary.  A loader included with the assembler was then used to place a binary image of the program anywhere desired in memory, regardless of assembly address.  That made it possible to assemble for the stack or zero page without actually overwriting either area.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 6:32 pm 
Offline

Joined: Thu Apr 23, 2020 5:04 pm
Posts: 53
John West wrote:
But not always always. Occasionally there's a need for assembling code to one location with the intent that it be copied to another before it is run (such as CHRGET in Microsoft's BASIC). Do any assemblers provide a way to do that? It's not something that would be used often, but it would be a useful feature to have.

vasm supports the rorg directive to do that:
Code:
$ cat r.s
 org $00
lab1:
 jmp lab1

 org $20
lab2:
 jmp lab2

 rorg $8000
lab3:
 jmp lab3

 org $10
lab4:
 jmp lab4
$ vasm6502_oldstyle -quiet -Fbin r.s
$ hexdump -C a.out
00000000  4c 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |L...............|
00000010  4c 10 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |L...............|
00000020  4c 20 00 4c 00 80                                 |L .L..|


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 22, 2024 9:18 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
erhanbaris, your English is very good for someone whose first language is not English.

John West wrote:
GARTHWILSON wrote:
in my experience with assemblers, .org very much does change where the code is laid down.
That's what every assembler I've used does, and it's almost always what you want.

But not always always. Occasionally there's a need for assembling code to one location with the intent that it be copied to another before it is run (such as CHRGET in Microsoft's BASIC). Do any assemblers provide a way to do that? It's not something that would be used often, but it would be a useful feature to have.

...and then there are linkers, which I suppose are primarily for when multiple people are working on different parts of the same project.  The first commercial assembler I used, 2500AD, used a linker, and I never did figure it out, only use the command line that was recommended by someone else, modifying it for each project's file names.  I haven't used that assembler in over 30 years though.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 23, 2024 7:26 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I haven't studied the behaviour of org in this assembler. But one common little difficulty - not really a difficulty, but often seen as one - is that, for example, code which lives in a ROM which will ultimately be accessed at say $8000 will have addresses in the ROM which start at $0000. There's a difference between the offset in ROM, and the address the 6502 sees.

I think this difficulty is resolved by the way in which the assembler can produce a binary, or the way in which that binary is used to produce a ROM image.

(In the case of emulators, of course the ROM image will be a binary file loaded by a program. In the case of physical systems, the ROM image will be fed to a programmer, or built into a bitstream, or loaded by a monitor.)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 25 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:  
cron