Hacker News new | past | comments | ask | show | jobs | submit login

Ok, so I've been taking a crack at this. Can you help me understand something? On page 8, figure 5, the production for the entire program starts

    '.SYNTAX' .ID .OUT('ADR' *) ...
but I'm having trouble understanding what the ADR code is supposed to do. By my understanding, that line should instead read something like

    '.SYNTAX' .ID .OUT('CLL *') .OUT('HLT') ...
where HLT is some code that causes the machine to halt, or possibly

    '.SYNTAX' .ID .OUT('B *') ...
using the otherwise-unused unconditional branch code, and then defining R on an empty call stack as a machine halt.



i think adr is the equivalent of '.long' in gcc or 'dw' in masm, though the description of the adr pseudo-operation is not very clear. it says it 'produces the address which is assigned to the given identifier as a constant'. on a stack/belt machine or an accumulator machine, 'produces' could conceivably mean 'pushes on the stack/belt' or 'overwrites the accumulator with', but the meta ii machine doesn't have an operand stack, belt, or accumulator; it has a return stack with local variables, an input card, an output card, and a success/failure switch, so it doesn't make sense to read 'produces' as a runtime action. moreover, 'adr' is not listed in the 'machine codes' section; it's listed along with 'end' in a separate 'constant and control codes' section, which makes it sound like a pseudo-operation like '.long'. i suspect 'end' tells the assembler to exit

i agree, it would make much more sense to say

    '.syntax' .id .out('cll ' *) .out('hlt')
and thus eliminate the otherwise-unused adr, or simply to put the main production of the grammar at the beginning of the grammar, which is what i did in meta5ix. i think they do define 'r' on an empty call stack as a machine halt, btw

they do mention this startup thing a bit in the text of the paper (p. d1.3-3)

> The first thing in any META II machine program is the address of the first instruction. During the initialization for the interpreter, this address is placed into the instruction counter.

so i think the idea is that their 'binary executable format' consists of the address of the entry point, followed by all the code, and the loader looks at the first word to see where to start running the code. this sounds stupid (because why wouldn't you just start running it at the beginning?) but elf, a.out, and pe all have similar features to allow you to set the entry point to somewhere in the middle of the executable code, which means you have total freedom in how you order the object files you're linking. so even though it's maybe unnecessary complexity in this context, it's well-established practice even 60 years later, and maybe it already was at the time, i don't know

i hope this is helpful! also i hope it's correct, but if not i hope it's at least helpful :)




Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: