From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 15 Feb 2008 20:11:07 +0000 To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Google search of the day From: "Eris Discordia" Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 References: <47B5E278.7030107@proweb.co.uk> Content-Transfer-Encoding: Quoted-Printable Message-ID: In-Reply-To: <47B5E278.7030107@proweb.co.uk> User-Agent: Opera Mail/9.23 (Win32) Topicbox-Message-UUID: 568e9f68-ead3-11e9-9d60-3106f5b1d025 On Fri, 15 Feb 2008 19:05:28 -0000, maht wrote= : > Forth doesn't use CALL it uses JMP > > Similar Threaded Interpretive Languages run an inner loop that does th= is = > pseudo code : > (from Threaded Interpretive Languages: Their Design and Implementation= = > by R. G. Loeliger) > > COLON: > PSH I -> RS > WA -> I > JMP NEXT > SEMI: > POP RS -> I > NEXT: @I -> WA > I +=3D 2 > RUN: @WA -> CA > WA +=3D 2 > CA -> PC > I know nothing about interpreted/interpretive languages but the above = pseudo-code is, to my own surprise, quite readable to me. The "indirection pointer" seems to funcionally match the (stack) base = pointer on x86, with the word address equalling the stack pointer. So, t= he = above says: - Save the stack base address (PSH is PUSH, I assume). - Set the stack base address to the beginning of the current frame. - Jump to NEXT. - Put the return address on top of the stack. - Reserve space on the stack for one 16-bit (2-byte) address by = incerementing the base pointer. On x86 one would decrement the base = because the stack grows from higher addresses towards 0x0. - Set the the call address to the beginning of the procedure. - Set the program counter to the procedure ("call" it, in other words). One strange thing is that code and (stack) data seem to both grow from 0= x0 = towards 0xFFFF unlike x86 where the code sits in low address and the sta= ck = grows downwards. You have re-implemented the calling mechanism. You stil= l = have a call stack and the pertaining problems, but you have lost the = convenience of a simple call instruction. By the way, now I see what Erik Quanstrom meant by "alternative" calling= = conventions. Your pseudo-code is an example. > that's all very well but you then extend the assembler parts with new = = > words made from the WAs (colon is the type marker for this) SEMI is = > where it JMPs to at the end > > moddiv: > colon > divmod > swop > semi I am genuinely lost, do not understand a word of it. -- = Using Opera's revolutionary e-mail client: http://www.opera.com/mail/