[Coco] 6x09/hello_os9-Commented

Allen Huffman alsplace at pobox.com
Sun Oct 1 21:31:40 EDT 2023


> The location of the post is:
>    http://jechar.ca/coco/Download/source/6x09/hello_os9-Commented.html

A lot of this you won’t ever “need” to understand — I wrote a lot of assembly utilities and even one game, without knowing what alot of it did ;-)

1) OS-9 runs position independent code so the programs can load anywhere in memory. As far as I know the ORG is always 0 since it will be placed in memory elsewhere (never at 0).

4) size will be the value of 128, and will be used later.

5) endpgm is another label, you will see it at 21.  It will be the offset(?) of where that is in the binary.

‘6) fcs - form constant string? I think. It’s a series of characters with a 0 added at the end.

	fcs ‘hello’

Will place:  ‘h’,’e’,’l’,’l’,’o’,0

If you use fcc, you do not get the added 0 at the end.

13) the b=0 is, if I recall, the error code to return when you exit. If you “lob #216” and then F$Exit, you will see it exits with a #126 (file not found) error. If you program can fail, you can set that register to an error code which will return to the shell. Or, if you are calling the program from another process, it will be the return value.  Like, in C “x=system(“myprog”)” x would return with that value.

16) hello is just a label, marking the start of the data at that location. TO get to that area in the binary you either would need the hard coded offset (from 0) or use the label hello.

18) feb is form constant byte. It puts in that byte literally. In this case,

	fcc ‘hello’
	fcb ’13’

That places, at that memory:

	’h’,’e’,l’,’l’,’o’,13

It is adding “hello”+carraige return.

$WritLn will write up to the byte max you specify OR up to when it finds a 13.

19) strlen is just a label, it could be anything.  You could say:

	howfar: equ *-hello

That makes “howler” equal from the start of the program (*) to where the hello label starts. That’s the offset from start of program to the hello text bytes.

21) never had to know… but I think the module header needs to know the end of the binary, so that’s why I guess.

		— ALlen



More information about the Coco mailing list