[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

338.0. "??? BCPL Pointer question ???" by CYCLPS::GIUSTI () Thu Feb 19 1987 22:17

Recently, I was looking over the Lattice C initial startup procedure for 
AmigaDOS in an attempt to gain some familiarity with 68000 assembly code.  I 
came across something that I do not quite understand...

The bit of offending code occurs during the CLI startup section, when the 
command name is searched for.  I have reproduced the code fragment below:

*------- find command name

clr.l	-(sp)
jsr	_FindTask
addq.l	#4,sp
move.l	d0,a0
move.l  pr_CLI(a0),a0
add.l	a0,a0			* bcpl pointer conversion
add.l	a0,a0

Why the BCPL conversion?  Is this something that a person using assembly 
language on the amiga should be aware of?
Also, why a JSR to _FindTask?  The same code uses the _LVOFindTask(a6) call in 
an early part of the program; why does it not do the same here?
(_FindTask is declared as XREF)

Thanks beforehand... ;^}

     	Ken

T.RTitleUserPersonal
Name
DateLines
338.1BCPL PointersTLE::RMEYERSRandy MeyersFri Feb 20 1987 11:1717
Re: .0

Most of the Exec and CLI commands are written in the language BCPL.  BCPL
is a typeless language that looks a lot like BLISS.  In fact, BCPL is
the common ancestor of C and BLISS.

In BCPL, or at least the version of BCPL used to write AmigaDOS, pointers
always point to a longword.  Since the pointers point to a longword, the
pointers are also shifted right by 2 bits.  Thus, to transform a BCPL
pointer to a machine address, you must multiply by four.

This is something that an assembler language programmer or even a C
programmer needs to keep in mind.  Some Exec data structures and AmigaDOS
calls use BCPL pointers.  (Intuition, on the other hand, was written in
C and uses real address as pointers.)  The documentation mentions if
something wants a "BPTR" or a "APTR".  A BPTR is a BCPL pointer; an APTR
is a actual address.