Re: Programming languages for the very young

From: Alex McDonald (alex_mcd_at_btopenworld.com)
Date: 01/30/04


Date: Fri, 30 Jan 2004 15:09:37 +0000 (UTC)


"Michael D. Ober" <obermd-.@.-alum-mit-edu-nospam> wrote in message
news:LDtSb.8$kg.19027@news.uswest.net...
>
> "Joe Marshall" <jrm@ccs.neu.edu> wrote in message
> news:3c9yep0t.fsf@ccs.neu.edu...
> > "Michael D. Ober" <obermd-.@.-alum-mit-edu-nospam> writes:
> >
> > > The last time I looked, all processors except the IBM mainframe
> processors
> > > have machine level SUB and RET instructions. These are the two
> instructions
> > > required for subroutines.
> >
> > You only need a conditional branch to get subroutines. It's a pain,
> > but you can do it.
>
> Actually, BAL does it with unconditional branches.

It's not that mainframes don't have SUB- and RET-like instructions; they do.
Co-incidentally, BAL (Basic Assembly Language) has an op-code called BAL. To
clarify;

BAL <reg>, <address>

Next instruction ip placed in <reg>, jump to <address>. It's _not_ a
straight jump. BAL (the opcode) is an acronym for Branch And Link.

BR <reg>

to return. Much more flexible; you've even got a choice of any of 15
registers. But there's no PUSH/POP-like equivalents for parameter passing as
there's no stack. [ Aside: the standard calling convention uses a register
pointer to parameters with doubly linked frames as register save areas. The
conventional call/return sequence is a little more convoluted than this
simple example; normally R14 and R15 are used as a call/return pair, R1 is
the parameter list pointer. ]

It's the lack of stack support instructions in hardware that's different
(although the x86 still requires OS support in addition). Supporting stack
operations on a mainframe is a pretty trivial job, though.

> My point was that
> subroutines are part of the stack machine model that just about every
> processor uses and that processors support them in machine code.

They're part of the stack-less machine model too.

-- 
Regards
Alex McDonald


Relevant Pages

  • Who Alberts additional assignment fosters, Fahd dares prior to favourite, white gardens.
    ... improved instructions try. ... regrets pairs in support of Ramsi's local philosopher. ... noisy or lexical will combine classical examinations to incidentally ... He may shall newly, unless Allahdad tests ...
    (sci.crypt)
  • [OOPS] 2.6.10-ac9 while watching TV and disk IO
    ... Trace; c0139998 ... This architecture has variable length instructions, ... This decode from eip onwards should be reliable ... # ACPI Support ...
    (Linux-Kernel)
  • Re: Higher Order Instructions
    ... push or pop instructions on the evaluation stack. ... higher order instructions to a stack machine these can be trivially ... this scheme amounts to macro expansion since e.g. your compose operation ...
    (microsoft.public.dotnet.framework.clr)
  • Re: feedback to NVidia [was: Nvidia Drivers]
    ... What "C" code causes these instructions to be generated by gcc. ... these engines in the existing gcc code base. ... "C" expect also a complementary lack of support for "C" in these ... Vendor support is my requirement! ...
    (Fedora)
  • Re: Could an Intel 486 wake up with FC3
    ... > aren't the sort of instructions that noticably accelerate programs. ... > don't include all the 686 support. ... i386/i686 rule is the kernel which is built as i586/i686 (why not build ... several core OS libraries and kernel with both i586 and i686 packages. ...
    (Fedora)