Re: LF: Still: fargo programming


[Prev][Next][Index][Thread]

Re: LF: Still: fargo programming



Oh, wait.  my mistake; you tried to clear the stack in the sub.  Don't do
this!  let the caller mess with the stack.

Let me put this anopther way.  When you call a sub., the processer pushes
the current address _onto the stack_, and then jumps into it.  All the rts
instruction does is to pop the top entry off of the stack, and jump to
there.  So when your sub. does the lea 4(a7),a7, it is actually removing
the return address from the stack!

Hope that helps.

--Shawn Walker

On Wed, 18 Jun 1997 Hmlacage@aol.com wrote:

> I don' t understand: i hadn' t been thinking much in my last email: what i
> had done was stupid....
> Howerver: here is what i don' t understand: i want to disp a message on the
> screen: i don' t want to use a macro ( it is some sort of exercise ) . 
> Here is a hello world prog. I would like to write a subroutine which disp a
> message  and wich uses the adress of the param as in param. Thus , i wrote
> the 2nd prog. ( see and of message ) What is wrong with it ? 
> 
>              @Program          prog_code,prog_name
> 
> 
> prog_code:
> 
>     jsr flib[clr_scr]
> 
> 
> main:
>     move.w   #4,-(A7)
>     pea      ess(PC)
>     move.w   #10,-(A7)
>     move.w   #10,-(A7)
>     jsr      romlib[puttext]
>     lea      10(A7),A7
>     jsr      flib[idle_loop]
>     rts
> 
> ess: dc.b "coucou",0
> 
> prog_name:
>   dc.b "essai",0
> 
>          reloc_open
>          add_library romlib
>          add_library flib
>          reloc_close
>          end
> 
> 
> 2nd prog: 
> 
>             @Program          prog_code,prog_name
> 
> 
> prog_code:
> 
>     jsr flib[clr_scr]
> 
> main:
>     pea      ess        ; Loads "ess" adress in the stack
>     bsr      affich
>     rts
>     
> affich:
>     move.l   D7,A1      ; gets back the param in A1
>     lea      4(A7),A7   ; puts the stack back to normal
>     move.w   #4,-(A7)   ;
>     pea      D7(PC)     ;    loading params for puttext  
>     move.w   #10,-(A7)  ;    
>     move.w   #10,-(A7)  ;
>     jsr      romlib[puttext]
>     lea      10(A7),A7
>     rts
> 
> 
> ess: dc.b "coucou",0
> 
> prog_name:
>   dc.b "essai",0
> 
>          reloc_open
>          add_library romlib
>          add_library flib
>          reloc_close
>          end
> 
> 


References: