[HN Gopher] Back to the future: Writing 6502 assembler with Amaz...
       ___________________________________________________________________
        
       Back to the future: Writing 6502 assembler with Amazon Q Developer
        
       Author : ingve
       Score  : 50 points
       Date   : 2024-11-04 17:02 UTC (5 hours ago)
        
 (HTM) web link (community.aws)
 (TXT) w3m dump (community.aws)
        
       | mxl9df wrote:
       | Interesting article, but the title is a bit off. "Assembler"
       | actually refers to the tool that converts assembly language into
       | machine code, not the language itself. So "writing 6502
       | assembler" would technically mean writing the assembler software,
       | not writing assembly code for the 6502 processor.
       | 
       | It's a small distinction, but surprising to see this mix up as
       | assembly language enthusiasts tend to be sticklers for these
       | details!
        
         | kjs3 wrote:
         | I don't know anyone who doesn't say "I wrote X assembler" with
         | complete understanding by all involved, and I definitely don't
         | know anyone so pedantic they said "acksually, it's 'I wrote X
         | assembly code'". I guess none of the dozens of assembly code
         | makers or whatever I've know over the last 40 years was enough
         | of a stickler. Or care one way or another.
        
           | rkeene2 wrote:
           | I also understood the title to mean writing an assembler
           | rather than writing assembly language code, and I've never
           | heard anyone refer to writing assembly as writing assembler
           | (or heard anyone who writes assembly referred to as an
           | "assembly code maker", nor anyone who writes in any language
           | referred to as an "<language> code maker").
           | 
           | I could imagine such phrasing being done by non-native
           | English speakers, of which I'm have no doubt that there are a
           | significant number.
           | 
           | My (unresearched) guess is that this is simply different
           | dialects of speakers emerging with respect to informal
           | references over the decades.
        
             | wtetzner wrote:
             | It seems to be pretty common even among native English
             | speakers to use "writing assembler" and "writing assembly"
             | interchangeably. If one were writing the tool that
             | assembles to machine code, you'd say "writing _an_
             | assembler ".
        
             | kwertyoowiyop wrote:
             | Using "assembler" instead of "assembly" was common enough
             | back in the day that there was no confusion. There were
             | 100x more people writing "assembler" than writing actual
             | "assemblers" so you know, the odds were good.
        
             | snozolli wrote:
             | _I 've never heard anyone refer to writing assembly as
             | writing assembler_
             | 
             | I used 'assembler' back in high school, when I was learning
             | about the 80x86. I remember because I was 'corrected' by
             | fellow student who had never touched assembler, assembly
             | language, machine code mnemonics, or whatever you want to
             | call it.
             | 
             | I have no idea where I got the terminology, but I was
             | reading a lot of books and Usenet posts on the subject at
             | the time. I'm a native English speaker, for what it's
             | worth.
        
               | ndiddy wrote:
               | > I used 'assembler' back in high school, when I was
               | learning about the 80x86. I remember because I was
               | 'corrected' by fellow student who had never touched
               | assembler, assembly language, machine code mnemonics, or
               | whatever you want to call it.
               | 
               | Wow, you got the Hacker News experience 30 years in
               | advance!
        
         | ryandrake wrote:
         | I had the same reaction. I first thought, well it's not _that_
         | difficult to write an assembler for a simple 8-bit instruction
         | set, but then upon reading the article it looks like it 's
         | instead writing programs _in assembly language_. Totally
         | different.
        
         | emptybits wrote:
         | I agree; I read the headline as meaning a 6502 assembler was
         | written, as opposed to 6502 assembly being written.
         | 
         | Writing compilers gets difficult, quickly. But writing
         | assemblers is/was common enough for simple architectures and
         | it's quite fun and relatively easy to prove/test for
         | correctness. At least compared to most compilers.
         | 
         | One of my first gigs out of school involved writing a Z80
         | assembler because I "needed" nonstandard (Sharp/DMG/8080)
         | instructions to be handled during a codebase port. It was
         | enjoyable! I recommend everyone write an 8-bit assembler at
         | least once!
         | 
         | Still, TFA is very interesting and I appreciate OP's share. :-)
        
           | PaulHoule wrote:
           | There was the time I wrote a "data-assembler" for the AVR8
           | because I was packing up rather complicated data structures
           | to represent parts of graphics that appear on a persistence
           | of vision display and how the parts are assembled into
           | images. If you look at any assembler you see there are a lot
           | of facilities for constructing data as well as for
           | constructing code and I took one approach to that problem,
           | outputting C code for an array that the system can read out
           | of the (comparatively large) ROM.
        
         | 0xcde4c3db wrote:
         | In my experience, this is a common enough usage variation that
         | I'm not sure how helpful it is to treat it as an error. In
         | particular, "assembler language" seems to have been IBM's
         | preferred phrasing at one point.
        
         | satiated_grue wrote:
         | As someone who's been writing assembly language for decades
         | going back to Univacs, most people used "assembler" as
         | shorthand for "assembly language" or even "assembler language".
         | It's usually quite unambiguous.
         | 
         | Here are examples of such usage, from 1967 and more recent:
         | 
         | http://www.bitsavers.org/pdf/ibm/360/asm/C28-6514-5_IBM_Syst...
         | 
         | https://www.ibm.com/docs/en/zos-basic-skills?topic=zos-assem...
        
           | pessimizer wrote:
           | Seems like they always start with " _the_ assembler language,
           | " which I take as "the language of the assembler," and then
           | they sometimes get sloppy after that. I've never heard
           | someone say "assembler language" (or maybe I just tuned it
           | out.)
        
             | AlotOfReading wrote:
             | It's definitely a thing that happens. I believe it comes
             | from the phrase "assembler language" that IBM manuals used
             | instead of "assembly".
        
         | Dwedit wrote:
         | Other mistakes everyone makes: Referring to an instruction as
         | an Opcode.
        
         | sehugg wrote:
         | And if you write an assembler in C#, you could have an
         | assembler in an assembly.
        
       | cpldcpu wrote:
       | Which LLM is Amazon Q based on?
        
         | bilekas wrote:
         | It's an internal as far as I remember. Used the be called
         | "Olympus". As for its public status I have no clue.
         | 
         | https://www.pymnts.com/artificial-intelligence-2/2023/amazon...
         | 
         | Edit : link
        
       | nxobject wrote:
       | This raises the question: what information did Amazon Q ingest to
       | be able to write C64 Basic, and from where - OCR'd books and
       | magazine off Google Books? Online tutorials? That would explain
       | whether it would be possible to adapt this workflow to supporting
       | other relatively obscure platforms, with a limited documentation
       | set that's certainly not available online on the internet in
       | easily parsable HTML: e.g. PDP-11 assembly, Turbo Pascal, classic
       | Macintosh/Macintosh Toolbox, etc.
       | 
       | Who knows, it might be a shot in the arm for retrocomputing
       | enthusiasts.
        
         | duskwuff wrote:
         | > classic Macintosh/Macintosh Toolbox
         | 
         | This one's probably pretty well covered, actually. All of
         | Apple's _Inside Macintosh_ documentation is available in PDF
         | format, and there 's plenty of old programming books and
         | magazines which have been scanned and OCRed.
        
         | 094459 wrote:
         | Yeah it lowers that barrier to getting re started. It did for
         | me at least
        
       | vardump wrote:
       | // Zero page variables       .const zp_x = $FB       .const zp_y
       | = $FE       .const zp_dx = $101       .const zp_dy = $104
       | 
       | AI extended zero page, I see... (zp_dx and zp_dy are in 6502
       | hardcoded stack range, not in zero page at all).
        
         | sehugg wrote:
         | I've noticed that LLMs have a hard time remembering all the
         | constraints of 8-bit programming. Like sometimes it assumes
         | that 6502 registers can have a value above 255, or in C it
         | assumes that ints have 32/64 bits.
        
         | surfingdino wrote:
         | $101? $104? This looks familiar. If you try to train an LLM on
         | series of lottery ticket numbers, say 1-50 and then ask for a
         | set of numbers based on the training data LLMs sometimes will
         | give you numbers like 110 or 101.
        
         | Dwedit wrote:
         | Also, if you have an _array_ living in the zeropage, and you
         | use Zeropage,X or Zeropage,Y instructions to try to access
         | beyond address FF, it will wrap back to 00. Because it 's a
         | zeropage instruction that can't go outside the zeropage.
        
       | PaulHoule wrote:
       | Reminds me a lot of BASIC I wrote back in the day, particularly
       | the code for the bouncing sprite.
       | 
       | Seriously though it makes me think of how hit-or-miss Microsoft
       | Copilot is at writing code (we have a special license to use it
       | at work.)
       | 
       | For certain things such as writing short bash, CMD.EXE and
       | PowerShell scripts it does great. It writes great list
       | comprehensions in Python. Can convert code defining a set of
       | typed dicts to a set of dataclasses. Can write a SQL query using
       | an obscure (to me) feature and then rewrite it in JooQ.
       | 
       | But write a CTE expression in JooQ? It doesn't understand how to
       | break the circularity.
       | 
       | Configure Vite? It will insist on the same wrong answers
       | ceaselessly. On the other hand, if you look at StackOverlow the
       | answer seems to be "you can't get here from there" or "there is
       | this plugin that might help if it worked but it doesn't."
        
       | 094459 wrote:
       | Author of the post here. Just reading the comments so apologies
       | for getting some of the terminology wrong. The intention was
       | never to mislead folk , just wanted to share my enthusiasm for
       | emulation and the fact that you could get working code.
        
       | russellbeattie wrote:
       | Shout out to Ben Eater for enabling me to understand this
       | article. Everything I know about Assembly and the 6502, I learned
       | from his videos.
       | 
       | https://eater.net/
        
       ___________________________________________________________________
       (page generated 2024-11-04 23:00 UTC)