[Coco] 6x09/hello_os9-Commented

coco at jechar.ca coco at jechar.ca
Mon Oct 2 13:25:32 EDT 2023


Thanks I feel much more confident now, ready to try something on my own.

On 2023-10-02 09:09, Joel Rees via Coco wrote:
> On Mon, Oct 2, 2023 at 10:04 AM coco--- via Coco <coco at maltedmedia.com> 
> wrote:
>> 
>> All
>> 
>> I received a "Hello World" sample program From Alex Evans, It works
>> well.
>> I have looked at it line by line trying to understand everything.
>> I still have some questions, so I have posted the code followed by a
>> table
>> with line numbers, code and comments/questions. This shows exactly 
>> what
>> I
>> understand or am guessing and what I am clueless about. Please take a
>> look at
>> it and using line numbers you can comment on the accuracy of my
>> understanding
>> of the code and the meaning of the lines of code I am clueless about.
>> 
>> The location of the post is:
>>      
>> http://jechar.ca/coco/Download/source/6x09/hello_os9-Commented.html
> 
> I suppose I shouldn't kibbutz, but it would be a lot easier to comment
> if you had put that in you email instead of in your blog.
> 
> There are reasons to ORG things to non-zero in OS-9 assembler, but I
> don't think you want to know those just yet.
> 
> As has been indicated, EQUating size to 128 and passing it as the 6th
> parameter to the mod directive tells the assembler to tell the linker
> the program will need 128 bytes of data space, as I recall the
> explanation.
> 
> Asterisk in an expression could be called the "here" operand. It
> evaluates as the current location to assemble at. Thus, when endpgm is
> EQUated to *, because we started with ORG 0, endpgm is the size in
> bytes of the executable object.
> 
> FCS is "form constant string", meaning a NUL terminated string. It
> implicitly tags a 0 byte on the end of the quoted string that gets
> assembled into the object code there.
> 
> Compare that to FCC, "form constant character", which does not
> automatically append a o byte.
> 
> LEA -- load effective address. The 6809 has a number of useful
> addressing modes. You tend to think of B,Y in
> 
> LDA B,Y
> 
> as simply the address to load A from. But LEAX B,Y computes the
> address and puts the address into X, instead of grabbing the contents
> of memory at that address.
> 
> In the case of LEAX hello, PCR, it's calculating the address of the
> FCC string at label hello relative to the PC, and loading the address
> into X. This is one of the keys to relocatable 6809 code. The
> assembler figures out the offset from the instruction to the string,
> and assembles that offset as the offset argument to the LEA in PC
> relative mode. That way, when the OS loads the code at, say, &7800
> instead of 0, the LEA still gets the right address for the string
> hello.
> 
> Hopefully, together with the other responses, this answers your 
> questions.
> 
> --
> Joel Rees
> 
> http://reiisi.blogspot.jp/p/novels-i-am-writing.html


More information about the Coco mailing list