🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.oberon
Article #820

Re: Coroutines for Oberon V4

#820
From: Claudio Nieder
Date: Tue, 23 Jan 1996 01:26
59 lines
3393 bytes
Hi,

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
Technical Details
Message-ID: <slrn4g8e9p.ug.claudio@cn.dial.eunet.ch>
Path: arc1-ca.pugleaf.net!EU.net!chsun!claudio
References: <slrn4g31s8.170.claudio@cn.dial.eunet.ch>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.oberon
Path: arc1-ca.pugleaf.net!EU.net!chsun!claudio
From: claudio@dial.eunet.ch (Claudio Nieder)
Subject: Re: Coroutines for Oberon V4
Message-ID: <slrn4g8e9p.ug.claudio@cn.dial.eunet.ch>
Sender: usenet@eunet.ch
Reply-To: claudio@dial.eunet.ch (Claudio Nieder)
Organization: A customer of EUnet AG, Switzerland
X-Newsreader: slrn (0.8.4)
References:  <slrn4g31s8.170.claudio@cn.dial.eunet.ch>
Date: Tue, 23 Jan 1996 01:26:22 GMT