abrasax: (c64)
Continued from where I stopped this morning: adding the * 'variable' feature to my fork of the LADS assembler.

Ever since I created Txula, my fork as it were, I've toyed with this idea of the *, only to drop it. I didn't conceive of a way to implement it until today. I'm gonna do it, damn it.

The *, used for arguments like JMP *+6, is a quick and dirty way to establish a location for JMPs, JSRs, BXXs that wouldn't rely on labels OR knowledge of the program counter's value. That's because assemblers that use the * interpret it to mean 'the current value of the program counter at the start of the current line' - or, at least, that's how I interpret the *. Point of Order: in assembly / machine language programming, the code sits in RAM and runs on RAM directly on metal as they say. The program counter is a CPU register that keeps track of the RAM location or position (ie addresses) where the current line of code exists. In reality there are no labels; labels only exist for the programmer's convenience; it's just raw RAM addresses.

First, the hard part: settling on how to use the * with my fork.

It's to substitute for a label, yes? So how do work with labels? With Txula I use the / and the & as prefixes to indicate how a label is going to be used: the /'s are for positionals and the &'s are for arguments.

Example 1
/loopLDA &buffer,y
BEQ &quit
JSR &print
INY
BNE &loop
/quitRTS


Example 1 is a block of code that uses a do loop structure. The /loop and /quit are positional labels that establish via the program counter where the loop starts and ends. The &buffer, &quit, &print, and &loop are argument labels used as opcode arguments. In both cases the label's actual name is the text that follows the / and the & prefixes. Neither LADS nor Txula put a lot of restrictions on the sizes or the names of labels. Rather, we've got guidelines: don't use DATA and REM or words that contain them since the BASIC tokenizer goes wonky if you do; don't make them too big (or too small); don't use special characters the assembler recognizes as delimiters. But the / and the & prefixes are entirely my own novelty and what sets my fork apart. I conceptualize it as 'strong typing' even though that's utter nonsense given that it's assembly.

So I decided to keep my prefix framework intact. Using the *, the same code as above reads:

Example 2
LDA &buffer,y
BEQ &*+8
JSR &print
INY
BNE &*-9
/quitRTS


Cleaner(ish); note how that the &'s are still required.

Then I decided that having any label start with the * up-ends the assembler's normal way of dealing with labels altogether.

If a positional label starts with *, /* or /*loop or /*quit, then the assembler treats that as a decoration. It skips processing it as a positional label but keeps it strictly for screen or printer output (hence why it's a decoration at that point). Further, if an argument starts with *, &*+8, or &*quit+8, then the assembler treats that as just the * with extra letters for decoration.

Why the decorative treatment? In Example 2 I've got BEQ &*+8 and BNE &*-9, both are conditional branching opcodes, kinda/sorta IF/THEN/GOTO's, so if they're triggered by a condition, they branch to the location specified by their arguments. In both cases though it's just the * with offsets, of course, but the *'s don't give you a lot of clues about what you were meaning to do, does it?

What if you had:

Example 3
/*loopLDA &buffer,y
BEQ &*quit+8
JSR &print
INY
BNE &*loop-9
/*quitRTS


You'd say well that's just as dreadful as the first example, mate. Not gonna argue with that (pun intended hahaha) but this third example, like the second example, doesn't have labels at all. The /*loop and /*quit are treated as decorations since *loop and *quit start with the *. Likewise the &*quit and &*loop aren't labels but (decorated) calls to the current program counter value. Except now they give you a visual clue about where you intend them to branch to. Ultimately, the two advantages to this are: speed and conservation of RAM. Speed - because you don't have to look up labels from the database. Conservation of RAM - because you don't have to waste precious RAM space adding labels to the database. (We've got 64 KB of RAM in the C64; only about 30 KB of which are reserved for the label database.)

To implement this I need to add two line parsing variables to keep track of the leading *'s; add a few lines of code to the labels database routines that circumvent its ordinary behavior, and add a few error traps to the codes that handle equates and label table pseudo-codes. Let me explain those last two bits.

So normally a label represents a program counter value were a line of code starts. We use this concept to name routines or jumping / branching points for later use. Thus, under ordinary conditions, when we reache a statement like /quit RTS, the "quit" label and value are saved to the database. Whereas when we reach a statement like BNE &loop, the "loop" label and value is loaded from the database so the BNE's argument can be determined. Yay.

But there's another way to force a label / value pair into the database and that's through the equate pseudo-code.

Equate Pseudo-Codes
LADS: print = $ffd2

TXULA: .= &print $ffd2 OR .= $ffd2 &print


The error trap here is that for an equate the &'s label can't start with the *.

As for the label table pseudo-code.... This is actually one of the things I was most proud of when putting Txula together. My LABView x-platform assembler had this ability and I wanted my fork to gain it. With this pseudo-code I'm able to make lists or tables that invoke the label's values, it would look like this

Lable Table Pseudo-Codes
.#= loop print quit


(this version, .#=, lays the values out as 2 bytes in lo/hi order) But, because anything starting with the * refers not to labels but to the program counter value, I can't have .#='s arguments start with the * either. I augment to code to trap that as an error.

Anyway, instead of writing, that's my afternoon. Amazingly, for such a major to do, so little to change at all.
abrasax: (c64)
In regards to my 6502 Assembler, a project I finished last week (was it last week?). So I awoke today with the strangest idea about how to include a functionality from other assemblers. I mean using the current program counter as the basis of an argument. In those contexts you'd often see statements like BCC *+9, the * referring to the current program counter value, the +9 or +,- anything being an offset to that. It's an alternative to using absolute values or labels. LADS didn't implement that; neither does my fork. But now I've got the urge to add that. LOL It wouldn't be too hard, either.
abrasax: (varang)
Today I juggled my two hobbies quite well. In the morning I drafted ~ 20 or so hardware routines - nearly the entire body of the routines I'd need for my assembly program project to go forward. In the afternoon I revised yet another chapter for Avatar/Backrooms. yay :D In the evening I almost finished my routines ... almost. I realized that for them to work efficiently, my routines for merging and appending strings had to be adjusted. Easy fixes ultimately. I design these programs so the routines live in their own spaces, with their own variables and can be stacked together without cross-contaminating each other. Still not done with either project but I'll take incremental progress over statis.

As for my Avatar/Backrooms work; I've been meaning to get into the deets here so let me try while I'm still awake. What I'm working on is only Arc 3; I've got 4 & 5 outlined but undrafted. Arc 3 consists of 10 chapters, 6 of which I consider almost fully edited, the rest are raw.

In brief, this is what they're about:

1 - Spider and Neteyam (as a na'vi) spend a weekend together in Colorado; this is Spider's first exposure to what na'vi even look like (he's lived a quasi sheltered life with Quaritch hahaha); it's an entirely non-linear chapter that tells the story backwards. It's got this 'archival' thread running through it. That's because - in order to quickly get up to speed with the whole Pandora thing - Spider's been listening to research logs by Tom Sully and Grace Augustine and those two just discuss everything so it madness. Neteyam, the boyfriend hahah, tries to be gentle revealing the admittedly difficult past Spider's parents (Miles and Varang) are responsible for. Also - the whole Backrooms thing....

2 - Grace & co are still trying to understand what the black death / plague running through the forests is about. This is a spicy chapter because much to my own surprise Grace and (na'vi) Payakan have a budding romance happening. We also learn a lot about Payakan's tragic past here (as well as Grace's).

3 - Varang breaks into Mile's house and they have a confrontation. She wants guns; turns out an upstart by the name of Wukula did a coup d'état that deposed her 15 years ago (after the disastrous war). He's ruining the mangkwan and she wants the RDA surplus weapons so she can get back into power. She claims she's not mad about how Miles totally stole Spider from her. But I think she's mad. And then along the way we learn something interesting about Miles Quaritch that might explain why his characterization is a bit different here.

4 - Spider is alone; and he's still getting up to speed with the Backrooms lore from the logs of the scientists who explored the place decades before. Like found footage horror but it's audio logs. Then we learn he's been going into Backrooms by himself ... and making his own audio logs along the way.

5 - Back to Grace & co, she hates this but in order to figure out what the plague is and how to defeat it, Grace realizes she's going to need the Backrooms to take her to Earth again. In this fic the Backrooms connect different worlds and when you arrive at a planet, it changes your body into a version that can survive on the planet; those would be the avatars. She ... turned against the RDA and hasn't been back to Earth in almost 20 years and really doesn't want to. But she knows Tom Sully used to keep a well stocked lab on their Colorado property (where coincidentally Spider is staying at but she doesn't know that....) Kiri volunteers to go to Earth with her (if she stays na'vi).

6 - After the confrontation, Parker visits Quaritch at the house. The Colonel was studying the 'evidence' Varang left behind along with her demands. And he realizes Wukula intends to strike the wind traders at a certain location. And that Varang wants to fight him there. A kind of three way aereal battle for dominance. The guns might be enough to give her advantage. So he convinces Parker to give her the weapons. He wants to get back in her good graces.

7 - Grace and Payakan explore the eastern side of the forest where the plague is thicker; she realizes something about the way it spreads and maybe its weakness.

8 - Two contrasting phone calls; Spider and Quaritch vs Spider and Varang. It's like Spider is the kid of a divorced couple and he's got to keep the peace between them.

9 - Ah, now we follow Spider as he goes into the Backrooms and really pushes forward. It's kind of freaky inside but the kid isn't afraid....

10 - Quaritch delivers the guns and sneaks into Pandora with Lyle and Hicks (from Aliens; hehehe). They're all na'vi-fied avatars thanks to the Backrooms. Quaritch then seeks out Peylak; he warns him about Wukula's attack and Varang's strike; and he wants to be an outrider to help defend them. (there's a history between these two; Miles owes him a few lives apparently).

The real fun arcs are the next two; I'm pushing myself to get through these chapters just to get there. After that I kinda / sorta understand the remaining plotlines and I certainly know how I want it to end. But I haven't gotten there yet. Anyway, I can't even stay awake anymore - signing off!
abrasax: (nostalgia)
I went to see Godzilla -0.0 yesterday evening (LOVED it). I didn't want to follow the results.... And I didn't check them until the movie ended at 1 am. HOLY SHIT wow! Georgia ... wow :D I was so worried that jackass Rick Jackson was going to be governor. Oh, what a relief.

Alright. Um, in terms of progress, I advance quite a bit. I completed 2nd round revisions for 5 out of 10 chapters so far. Of the remaining chapters, the first three are short, the last two are long - sigh. I want to complete this entire round of revisions by the weekend and I believe it's possible if I simply don't do anything else. I'm thoroughly amused at how strong these chapters have been. They're not ready to post as they are for reasons. After these revisions, I'll go through them, one by one, until I finalize them. For that I'll take my time. AO3 won't be ready to go live anytime soon so what's the hurry anyhow?

Tangentially - I want to write drabbles again when I'm not working on this Avatar/Backrooms stuff.

Anything else? My two programming projects also advanced.

First, I completed my documentation of the MOS 6502 assembler I put together last year. All of it done by hand because of course I'm a geek. And every line of every routine is essentially documented. Eventually I want to transform that into a book ala Richard Mansfield's "The Second Book of Machine Language" which, to be fair, is what inspired my assembler.

Second, my self-imposed grading project chugs along at its glacial pace. I'm on the verge of completing a body of functions in machine language that replicate parts of C64 BASIC. The parts that remain 'to do' are functions for file operations (open, close, input, output).

I want to post more about this ancient style of programming generally. I talked about it a couple of times only briefly. Just to go into how an assembler works, I need to get into the dirty details of the CPU, the instruction set, addressing, etc. It's overwhelming so I need to stop myself. Hah, I got to be systematic about this.

OK, I'm sleepy AF, that's enough.
abrasax: (Default)
I'll preface this by specifying it's only valid for the C64's BASIC v2 and, obvs, 6502 assembly. Further, BASIC didn't require spaces between keywords & arguments; in fact, BASIC programs were smaller and faster when the spaces were omitted. Even further - and ridiculously technical - the C64 used PETSCII not ASCII (see C64 PETSCII Codes). And yet another point of order, values will be given in $HEX / DECIMAL the first time you see them.

( ... go ahead jump right into the cut ... )
abrasax: (nostalgia)
Whilst I'm bored at work waiting between meetings, I'm going to take the opportunity to write about my other geeky hobby, retro!programming.

( ... this sure isn't fanfic anymore ... )

Profile

abrasax: (Default)
Abraxas

Badges

NSFW/18+LGBT PrideBelieves in ScienceFilm BuffWriterPhotographerAvatarVarang from Avatar Fire and Ash

November 2026

S M T W T F S
1 2 3 4 5 6 7
8 9 10 11121314
15161718192021
22232425262728
2930     

Syndicate

RSS Atom

Style Credit

Powered by Dreamwidth Studios
Page generated 2026-11-11 08:59 pm