Re: Programming languages for the very young
From: Alex McDonald (alex_mcd_at_btopenworld.com)
Date: 01/30/04
- Next message: The Ghost In The Machine: "Re: Mars Rover Not Responding"
- Previous message: Michael D. Ober: "Re: Programming languages for the very young"
- In reply to: Michael D. Ober: "Re: Programming languages for the very young"
- Next in thread: Ray Dillinger: "Re: Programming languages for the very young"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: The Ghost In The Machine: "Re: Mars Rover Not Responding"
- Previous message: Michael D. Ober: "Re: Programming languages for the very young"
- In reply to: Michael D. Ober: "Re: Programming languages for the very young"
- Next in thread: Ray Dillinger: "Re: Programming languages for the very young"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|