[comp.sys.handhelds] assembly wierdness

bgribble@jarthur.claremont.edu (Bill Gribble) (11/27/90)

Let me disclaim by saying that I already know that the answer to this 
  question is a one-liner on the order of 'set file type to binary, you 
  fool.' (that's *not* the answer, by the way - just something equally 
  stupid.)

After compiling a simple program in asap - well, here it is:

----------------------------------------

        push_r0_short=#06537

        data.a  #02d9d          ; PRG
        data.a  #02dcc          ; mcode segment 1
pt1beg: data.a  pt1end-pt1beg   ; size of object
        call.3  push_short1
        move.a  @d0,a
        add.a   5,d0
        jump.a  @a
pt1end:

        data.a  #02dcc
pt2beg: data.a  pt2end-pt2beg
        move.a  @d0,a
        add.a   5,d0
        jump.a  @a
       
push_short1:
        clr.w   a
        inc.a   a
        move.w  a,r0
        call.a  push_r0_short
        ret
pt2end:

        data.a  #0312b          ; END

------------------------------------------------------

I'm just trying to test whether the intuitive assumption that code can be
  called between objects is true - of course it is, but that's not the point.

When I assemble and download, I get an object that looks like Code Code on
  the stack - just what you'd expect.  But when I  hit the softkey
  labeled 'TEST2', which is where it's stored, I get 'TEST2' on level 2 and 
  Code Code on level 1 rather than having the code evaluated.  Hitting
  the EVAL key gives 'TEST2' on level 4, Code Code on 3, EVAL (no delimiters)
  on 2, and <1h>, the intended result, on level 1.  What gives?

I think it's my exit code failing to do the right thing, but it follows 
  logic, examples, and past experience pretty well, so I don't know.
  Any help would be appreciated.

*****************************************************************************
**   Bill Gribble                     Harvey Mudd College, Claremont, CA   **
**   bgribble@jarthur.claremont.edu   Never heard of it?  You're stupid.   **
*****************************************************************************

bson@rice-chex.ai.mit.edu (Jan Brittenson) (11/28/90)

In article <9811@jarthur.Claremont.EDU> 
   bgribble@jarthur.claremont.edu (Bill Gribble) writes:

>        push_r0_short=#06537

>push_short1:
>        clr.w   a
>        inc.a   a
>        move.w  a,r0
>        call.a  push_r0_short
>        ret

   This isn't going to do what you're expecting. The routine at #6537
expects you to have previously saved the registers with a call to
#679b. Change it to:

	push_r0_short=#6537
	save_regs=#679b

push_short1:
	clr.w	a
	inc.a	a
	move.w	a,r0
	call.a	save_regs
	call.a	push_r0_short
	ret