LF: Once more: prog stuff


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

LF: Once more: prog stuff



I finally made a prog wich works but i don' t understand why: i thought that
: 
"pea    ess(pc)" is an instruction which does: "ess adress" + pc --->
stack...
This seems to be wrong: pea is 3 lines before the move a1,-(a7) wich pushes
the param for the puttext sub. Thus, pc is smaller when pea is executed than
when the adress is pushed for in param. Thus, the adress given to puttext is
diff from that which was given by the very simple hello world prog in last
message. However, it works... Thus, i am wrong...
Could someone please explain me exactly what is PC, what is his value and
what do "pea ess(PC)" do...
( see end for suite of this message ) 

prog_code:

    jsr     flib[clr_scr]
    pea     ess(PC)
    move.l  (A7)+,A1
    bsr     affich
    jsr     flib[idle_loop]
    jmp     quit
    

affich:
    move.w   #4,-(A7)
    move.l   A1,-(A7)
    move.w   #10,-(A7)
    move.w   #10,-(A7)
    jsr      romlib[puttext]
    lea      10(A7),A7

quit:
    rts


ess: dc.b "coucou",0


suite: btw, answering to shawn: what you said about the sub is that when
writing "bsr  something" , the processor stores the value of PC in the stack
and pops it back when writing " rts" . Thus, if i need to use the stack in a
sub, i need to bring  the stack pointer to exactly the same adress than at
the begening of the sub ? 
If so, it is not very interesting to use the stack to pass params to a sub:
1st, it takes more time than using the registers, 2nd, you need to care to
the stack pointer at the end of sub...

BTw, could someone show me the peice of code which does: 2+5=7( in fact
decimal add, mult....) 

Sorry for my english...
Mathieu, <hm lacage@aol.com>


Follow-Ups: