Article View: comp.lang.oberon
Article #824Re: Coroutines for Oberon V4
From: Christian Hoffmann
Date: Tue, 23 Jan 1996 15:04
Date: Tue, 23 Jan 1996 15:04
72 lines
3817 bytes
3817 bytes
Hi, Vielen Dank. Klingt etwas laenglich, ich werde damit so schnell nicht zurande kommen. Gruss >it seems I forgot to explain, what is exactly needed to port Coroutines >to other Oberon implementations. If you successfully ported Coroutines, >please send me your version, so that I can updated mine, and >redistribute it. > >I'll explain what to do using the AXP example. > >CONST > (* AXP: *) MP=29; SP=30; negativeGrow=TRUE; align=16; TYPE LONGINT=SYSTEM.SIGNED_64; > >The first constant (MP) is the register number used in REG() and >SETREG() for accessing the Mark Pointer. The mark pointer is the >register which is used for accessing local variables in procedures. The >second constant (SP) is the register number used for the Stack Pointer. >The third constant defines, whether a push on the stack will decrement >(negativeGrow=TRUE) or increment (negativeGrow=FALSE) the stack pointer. >The fourth constant defines the boundary to which a stack has to be >aligend. This is the stack hast to start ion an address, such that this >address modulo align is 0. > >The TYPE declaration is needed on AXP, as the return type of SYSTEM.ADR >is not LONGINT as on most other systems. In Modula-2, SYSTEM.ADR would >return the special type SYSTEM.ADDRESS, which is not existant in Oberon, >thus I supposed, that every implementation would have SYSTEM.ADR return >LONGINT. > >How does one find the correct values for those constants. The best >solution would be to find them in some documentation. If none is >available, one can do intelligent guesses using test programs and a >disassembler, if one is supplied with the given Oberon implementation. > >In module CoTest which I included in my first distribution, you might >have seen the procedure regTest and might have wondered what its scope >ist. It contains a row of SETREG and REG statements with register >numbers from 0 up to 255. I compiled this, to first see, which were >accepted by the compiler and which were rejected, because of invalid >register numbers. Then I commented out the invalid ones, and recompiled >CoTest. Then I disassembled it and lookued up, where the register number >in the assembler instruction was replaced by SP or MP. > >If you just see SP and no MP, then look at how the code for accessing a >local variable looks like. If it uses the stack pointer as base, then >your compiler uses the stack pointer also as mark pointer, and you >should use the same constant for SP and MP. > >For finding the value for negativeGrowth, one would look at the >procedure start and end, to see whether it somethinge like DEC SP...INC >SP (negtiveGrowth=TRUE) or INC SP ... DEC SP (negativeGrow=FALSE). > >For the alignment, you simply have to know. I would guess that 4 times >the processors word size is a good guess (32 bit = 4 byte => 16). If it >is too large, then it takes off a bit too much from your stack, but it's >just a few bytes, so it doesn't really matter. > > claudio >-- >claudio@dial.eunet.ch, Claudio Nieder, Kanalweg 1, CH-8610 Uster, Switzerland > > > Christian Hoffmann Swiss Federal Institute for Forest, Snow and Landscape Research CH-8903 Birmensdorf, Switzerland phone: ++41-1-739 22 77 fax : ++41-1-739 22 15 e-mail: hoffmann@wsl.ch
Technical Details
Message-ID:
<9601231501.AA07774@lagonda>Path:
arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.chShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.ch From: hoffmann@wsl.ch (Christian Hoffmann) Newsgroups: comp.lang.oberon Subject: Re: Coroutines for Oberon V4 Date: 23 Jan 1996 16:04:47 +0100 Organization: Dept. Informatik, Swiss Federal Institute of Technology Sender: server@inf.ethz.ch Distribution: world Message-ID: <9601231501.AA07774@lagonda> Reply-To: oberon-news@inf.ethz.ch NNTP-Posting-Host: neptune.inf.ethz.ch Originator: oberon-news@inf.ethz.ch X-Mailer: Windows Eudora Version 1.4.4