Made my first assembly program just now. :) http://snarc.net/h.jpg I was nudged by Ragooman, inspired by attending Kfest, and grateful for the book "Apple Roots" (the previously recommended book "Assembly Lines" left my brain in a knot after 5 pages). I read chapters 1, 3, and 4 -- skipped chapter 2 about number systems because I already understand that well enough to fake it and it didn't seem pivotal to * jumping in and doing something *. I used ProDOS Assembly Tools which I downloaded from the Asimov site. (Adam convinced me to switch to a real program like Merlin soon.) Tried the sample program (ADDNRS) in chapters 3/4 and got it to work after Facebook user Katherine S. in the Apple II group noted that I was missing some spaces in the sample code. After that it assembled without errors. Our own list member Paul H. provided additional insight. Then, armed with sleep-deprived confidence, I went back and applied what I learned to the "HI" example in chapter 1. That worked too, so I looked up the number chart at the back of the book and changed it to HELLO WORLD. It worked but I had a typo in the output: it showed a hyphen instead of a space. That was a good thing because it forced me to download the manual and learn how to load and edit the listing. Corrected it and this time it showed HELLO WORL ... what happened to the D? Looked again and I'd forgotten the final $FDED to display what I LDA'd. Okay then! Now it works. I have absolutely no clue if this is the "correct" way to make a hello world in Apple II 6502 assembly. I understand there's probably a more efficient way to do it. But for now, I basically skimmed three of the first four chapters and wound up with this: 1 ORG $1000 2 LDA #200 3 JSR $FDED 4 LDA #197 5 JSR $FDED 6 LDA #204 7 JSR $FDED 8 LDA #204 9 JSR $FDED 10 LDA #207 11 JSR $FDED 12 LDA #160 13 JSR $FDED 14 LDA #215 15 JSR $FDED 16 LDA #207 17 JSR $FDED 18 LDA #210 19 JSR $FDED 20 LDA #204 21 JSR $FDED 22 LDA #196 23 JSR $FDED 24 RTS Efficient or not, it works! ________________________________ Evan Koblentz, director Vintage Computer Federation a 501(c)(3) educational non-profit evan@vcfed.org (646) 546-9999 www.vcfed.org facebook.com/vcfederation twitter.com/vcfederation instagram.com/vcfederation
I was nudged by Ragooman, inspired by attending Kfest, and grateful for the book "Apple Roots"
Speaking of which: I'm working from the PDF found on Archive.org (thanks Adam). The actual book is more than $100 online! That is nutty. I will soon be looking for helpers to sort through VCF's dozens of disorganized book boxes. :) Hopefully we own a copy. I could print the PDF but it's not the same.
On 7/30/2017 4:21 AM, Evan Koblentz via vcf-midatlantic wrote:
I was nudged by Ragooman, inspired by attending Kfest, and grateful for the book "Apple Roots"
Speaking of which: I'm working from the PDF found on Archive.org (thanks Adam). The actual book is more than $100 online! That is nutty. I will soon be looking for helpers to sort through VCF's dozens of disorganized book boxes. :) Hopefully we own a copy. I could print the PDF but it's not the same.
That looks like an excellent book, Evan. You have Crossed the Rubicon.
On Sun, 30 Jul 2017, Evan Koblentz via vcf-midatlantic wrote:
Made my first assembly program just now. :) ...
1 ORG $1000 2 LDA #200 3 JSR $FDED 4 LDA #197 5 JSR $FDED 6 LDA #204 ...
Congratulations! One "comment": comment your code. :-) Mike Loewen mloewen@cpumagic.scol.pa.us Old Technology http://q7.neurotica.com/Oldtech/
glad to see you make the jump to hyperspace ;) When you get more practice with this, I would suggest using a 6502 cross-assembler, Apple emulator, There's many cross-assemblers for the 6502 that can do the job Both tools have been supported greatly over the decades, and just about any editor on your laptop will do with typing in the code Plus it lets you code anywhere you want, on the desktop, or laptop, or anywhere you go, without being limited. It's very practical and relaxing to have that freedom to code anywhere you go. And especially when your code starts to get much larger, eg. you have a bigger viewing screen to work with, to see more than 25 lines, etc all of your programming tools are at your fingertips, eg, don't need to use ADTPro every time on your Apple ][ The benefit of the cross-assembler allows you to build your code on some other desktop/laptop, 1st. because its faster, 2nd, you have more resources. 3rd, cause its cool :) You might say it''s being spoiled, But think back to the Altair Basic, that code was built on a PDP-10 because of these reasons [maybe not the 3rd] there's a whole story about the method they used, its a good read and so it will output 6502 machine code directly into a file that's compatible for your vintage computer. Remember, then I would would just use Ciderpress to build a Prodos disk image and send that to you, after coding with the editor on laptop, but I also recall you can just send the *.src.o file via ADTPro, so you can use the same floppy disk if it has enough space
From your last Lego Robot project this past winter, I found a lot of support for the emulators, especially when all I had within arm's reach was my laptop during my last recovery. The one limitation I had then was that the emulators didn't support many of the external interfaces, such as that 9750 Lego Robot Interface box, so I had to build some workarounds in the code
about printing Text on the screen, There are many of these assemblers and cross-assemblers which have a feature called Macro's This is not specific to a computer platform, just the developer who wrote the code for the assembler I use dozens of Macro's for my C64 assembly code, Basically these are the same snippets of code you find in the various examples, like others mentioned here, but then you have to convert the code somewhat so it conforms with the other Macro's, it's a type of software interface, This is sort of like writing a subroutine, which relies on certain variables to pass the information to compute. But then each of these Macro's use the 6502 registers to pass this information, and sometimes a value in a memory address, And the conforming process defines how you make use of the 6502 registers One can be used as the input variable, another would be the output variable, etc, etc At the same time, it reduces the amount of code you have to type, or even copy/paste. And these handful of Macro's would be kept in a separate "Include" file, you should learn this in a later chapter in that book. Because when you build your code, the assembler will automatically insert this snippet of code from the Include file which contains your Macro, directly into spot of the your code where you called it. This is just an overview, there should be more info in that book to explain this in more detail about what Mike said, definitely use comments, that might sound like an old fart's reason, but it was common practice 30++yrs ago, not sure how it's regarded in today's work environment, but I've noticed nobody has the same thought about this anymore. It was mostly because somebody that came after you on the job, when they had to update or fix the code, and if they had to spend more than enough time to rethink about why you create some function or subroutine that's spent money on the company's time, and so the boss didn't like to see time wasted, because 6mons or more from now, when you take a break or worked on another project, and mainly for personal benefit, and when your code gets larger, and then you go back to that previous project, there might be some code in there, not the obvious stuff, but some code which you had to brainstorm and create, and you find yourself having to rethink what or why you created it, this can get annoying sometimes, it's very easy for code to look obfuscated, even when you didn't try :) but also with your own creations, unless you add comments to describe the purpose, or reason, or what its for, or why i did this, etc, etc you don't need a paragraph in there, but maybe just a couple of lines, all depending on how much work it took you to create that snippet of code about searching for books, my first goto place is always with archive.org plus there's still 2nd,3rd,4th sources as well recall when we were online just the other day, I immediately mentioned it's available on there I'm glad to see they had this one too Dan excuse my rambling
When you get more practice with this, I would suggest using a 6502 cross-assembler
Yup, that's the plan.
about printing Text on the screen, There are many of these assemblers and cross-assemblers which have a feature called Macro's This is not specific to a computer platform, just the developer who wrote the code for the assembler
I understand what you're saying. However, as I learn, I want to be very careful to avoid confusing stuff that's part of Apple 6502 assembly vs. stuff that's part of any specific editor/assembler. I may not know the difference at first.
about what Mike said, definitely use comments
I know.
participants (4)
-
Dan Roganti -
Douglas Crawford -
Evan Koblentz -
Mike Loewen