Page 4 of 9

New productivity upload: X16 Edit - a text editor

Posted: Mon Oct 04, 2021 4:49 pm
by TomXP411


On 10/3/2021 at 8:22 PM, Ed Minchau said:




I don't use macros at all; my editor doesn't have that feature. I can however copy and paste code. 



Macros don’t come from the editor. The assembler does that. Technically, it’s part of the preprocessor, but most assemblers just integrate the preprocessor and the actual assembler.

So there’s usually a MACRO statement, which you follow with assembly code, like this:
name    .macro
jsr print
.null "Hello @1!";first parameter
.endm

Source:  http://tass64.sourceforge.net/#macro 

Then you will invoke the macro, which replaces the macro call with the actual assembly:

#name “Tom”

Now you can use that anywhere in your code as a shorthand for a larger procedure. While this is obviously a trivial example, it’s very useful for doing repetitive tasks, like setting up KERNAL calls or 16-bit math. For example:

Add16 (adds two 16 bit numbers and stores the result in the specified address)

Print (takes the address of a null-terminated string and prints that to the screen using CHROUT)

Open and Close (for file I/O)

While Add16 seems trivial, it’s much easier to write something like Add16 Addr, 23 than to repeatedly write out the the several lines of code needed for a simple 16 bit add. 

Another reason macros are useful over copypasta is that you can fix a bugged macro much more easily than dozens or hundreds of places in a program where you repeat a piece of code. If it turns out you forgot to clear the Carry flag before an add, and you pasted that 130 times, you’d have to fix 130 instances of your error. But if you make an Add16 macro, you can do it in the macro, then just re-assemble the program.

 


New productivity upload: X16 Edit - a text editor

Posted: Mon Oct 04, 2021 10:49 pm
by Ed Minchau


On 10/4/2021 at 10:49 AM, TomXP411 said:




Macros don’t come from the editor. The assembler does that. Technically, it’s part of the preprocessor, but most assemblers just integrate the preprocessor and the actual assembler.



So there’s usually a MACRO statement, which you follow with assembly code, like this:


name    .macro
jsr print
.null "Hello @1!";first parameter
.endm



Source:  http://tass64.sourceforge.net/#macro 



Then you will invoke the macro, which replaces the macro call with the actual assembly:



#name “Tom”



Now you can use that anywhere in your code as a shorthand for a larger procedure. While this is obviously a trivial example, it’s very useful for doing repetitive tasks, like setting up KERNAL calls or 16-bit math. For example:



Add16 (adds two 16 bit numbers and stores the result in the specified address)

Print (takes the address of a null-terminated string and prints that to the screen using CHROUT)

Open and Close (for file I/O)



While Add16 seems trivial, it’s much easier to write something like Add16 Addr, 23 than to repeatedly write out the the several lines of code needed for a simple 16 bit add. 



Another reason macros are useful over copypasta is that you can fix a bugged macro much more easily than dozens or hundreds of places in a program where you repeat a piece of code. If it turns out you forgot to clear the Carry flag before an add, and you pasted that 130 times, you’d have to fix 130 instances of your error. But if you make an Add16 macro, you can do it in the macro, then just re-assemble the program.



 



The problem for me is that I'm using the META/L editor, which is just a fancy monitor program with labels. There is no re-assembling the program, because all commands are converted into machine language as I type them. So, no macros.


New productivity upload: X16 Edit - a text editor

Posted: Mon Oct 04, 2021 11:28 pm
by BruceMcF


On 10/4/2021 at 6:49 PM, Ed Minchau said:




The problem for me is that I'm using the META/L editor, which is just a fancy monitor program with labels. There is no re-assembling the program, because all commands are converted into machine language as I type them. So, no macros.



Aha, a lot of people will assume you mean editing assembly language source (either a text editor or an assembler's IDE) when you refer to META/L as an "assembly editor".

The editing that is done is more directly editing the binary image, rather than editing assembly language source ... but OTOH it is not a classical binary editor, since it translated from assembly or character codes to binary.

If the clarification is that it's a fancy monitor with labels, that might be a better way to classify it ... the META/L monitor w/labels.

 


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 7:16 am
by TomXP411


On 10/4/2021 at 3:49 PM, Ed Minchau said:




The problem for me is that I'm using the META/L editor, which is just a fancy monitor program with labels. There is no re-assembling the program, because all commands are converted into machine language as I type them. So, no macros.



Ah. I think there's an assembler that runs on the Commander.... if there's not, I think it's high time we build one. 

 


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 4:14 pm
by Scott Robison


On 10/5/2021 at 1:16 AM, TomXP411 said:




Ah. I think there's an assembler that runs on the Commander.... if there's not, I think it's high time we build one. 



 



I've started one several times but just don't have the free hours to put into it.


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 4:39 pm
by Edmond D


On 10/5/2021 at 12:16 AM, TomXP411 said:




Ah. I think there's an assembler that runs on the Commander.... if there's not, I think it's high time we build one. 



 



There is one hopefully going into the ROM (https://sites.google.com/view/x16asmenv/home), but the aim is to provide a simple tool. Macros not included. 



 


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 7:59 pm
by TomXP411


On 10/5/2021 at 9:14 AM, Scott Robison said:




I've started one several times but just don't have the free hours to put into it.



I have written an 8080 assembler in c#... so I know I can write a simple assembler in c. The issue is, as you said, I've only got so many hours a day. Right now, I'm learning a new musical instrument, starting to arrange songs for a brass band, and working 50 hours a week... so I don't have a huge amount of free time either. ?

Still, I might see how hard it is to do... maybe the solution is to port over something like Turbo Assembler, which already runs on the Commodore 64. 

 


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 8:03 pm
by Ed Minchau


On 10/4/2021 at 5:28 PM, BruceMcF said:




If the clarification is that it's a fancy monitor with labels, that might be a better way to classify it ... the META/L monitor w/labels.



 



It's in sort of a weird space in between monitor and editor. I'm writing the code directly, and can use the labels as part of the parameters,  but I can also insert and delete bytes as if I was making room in a text editor, and can copy or move code around.  The mnemonics are slightly different from the standard notation, too.


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 8:56 pm
by Edmond D


On 10/5/2021 at 12:59 PM, TomXP411 said:




I have written an 8080 assembler in c#... so I know I can write a simple assembler in c. The issue is, as you said, I've only got so many hours a day. Right now, I'm learning a new musical instrument, starting to arrange songs for a brass band, and working 50 hours a week... so I don't have a huge amount of free time either. ?



Still, I might see how hard it is to do... maybe the solution is to port over something like Turbo Assembler, which already runs on the Commodore 64. 



 



Perhaps a community-based group approach? I like many don't have a ton of free time, but there are many talented programmers here that perhaps could spend 2-3 hours a week on a group project. 



My other suggestion is to extend  the X16 Assembly Environment to support macros as an addition, rather than building a whole new tool or porting another design.


New productivity upload: X16 Edit - a text editor

Posted: Tue Oct 05, 2021 9:55 pm
by TomXP411


On 10/5/2021 at 1:56 PM, Edmond D said:




Perhaps a community-based group approach? I like many don't have a ton of free time, but there are many talented programmers here that perhaps could spend 2-3 hours a week on a group project. 



My other suggestion is to extend  the X16 Assembly Environment to support macros as an addition, rather than building a whole new tool or porting another design.



The X16 Assembly Environment isn't really an assembler. It's a replacement for the machine monitor. Just like you wouldn't write code with Supermon, you shouldn't be using the Assembly environment to write code: you might use it to enter already-written code, or to debug, but if you're writing a non-trivial piece of software, you need to be using a traditional assembler, not the X16AE.