home .. forth .. colorforth mail list archive ..

Re: [colorforth] new color


Hi all, 
Mark, thanks for clarity.


On 6/4/05, Mark Slicker <maslicke@xxxxxxxxxxx> wrote:
> On Sat, 4 Jun 2005, Ray St. Marie wrote:
> 
> > And there you go. Proof of the ambiguity about how these things work.
> 
> There is no ambiguity here, but I see some confusion in your understanding
> of a subroutine call. Lets try an example with your 'array'.
> 
> : string pop ;
> : array string 2/ 2/ ;
> : test align array 1 , 2 , 3 ,
> 
> Suppose I enter this in a block, compile it. I've dissasebled the output
> below so perhaps this is more clear to you:
> 
> string:
>   8149fbb:       lea    -4(%esi),%esi
>   8149fbe:       mov    %eax,(%esi)
>   8149fc0:       pop    %eax
>   8149fc1:       ret
> array:
>   8149fc2:       call   0x8149fbb
>   8149fc7:       sar    %eax
>   8149fc9:       sar    %eax
>   8149fcb:       ret
> test:
>   8149fcc:       nop
>   8149fcd:       nop
>   8149fce:       nop
>   8149fcf:       call   0x8149fc2
>   8149fd4:       .int 1
>   8149fd8:       .int 2
>   8149fdc:       .int 3
> 
> Above you see the effect of the macros (pop, 2/, align). I'd like to show
> a trace of this program, I'll use the following notation for the stacks:
> 
> ( d2 d1 d0 -- r0 r1 r3 )
> 
> d0 and r0 denoting the top elements of the data and return stack
> respectively. Starting with 'test' (8149fcc):
> 
> test:
>   8149fcc: nop                ( -- )
>   8149fcd: nop                ( -- )
>   8149fce: nop                ( -- )
>   8149fcf: call   0x8149fc2   ( -- )
> array:
>   8149fc2: call   0x8149fbb   ( -- 0x8149fd4 )
> string:
>   8149fbb: lea  -4(%esi),%esi ( -- 0x8149fc7 0x8149fd4 )
>   8149fbe: mov    %eax,(%esi) ( -- 0x8149fc7 0x8149fd4 )
>   8149fc0: pop    %eax        ( 0x8149fc7 -- 0x8149fd4 )
>   8149fc1: ret                ( 0x8149fc7 -- 0x8149fd4 )
>   8149fd4: ...                ( 0x8149fc7 -- )
> 
> At this point in the trace, you've started to execute the data you had
> defined ( 1 , 2 , 3 , ), I hope it is clear why this defintion of array is
> incorrect. I also hope this gives you a better appreciation for call/ret.
> 
> Mark
 
Thanks Mark, I'm better for this. I wish I new the fundementals of asm
programming but I never learned them. I was not aware that the word
called returned to the next word in the calling word. This is why I've
stuck with jumptables, rather than arrays, because I truely was
unaware of the way things work. If you have a trusted referance,
please recommend.

This changes all I know about pop. 
Ray

-- 
Ray St. Marie
Rastm2ATusersDOTsourceforgeDOTnet
Ray.StMarieATgmailDOTcom and ATsbcglobalDOTnet
Ray_stmarieAThotmailDOTcom
Raystm2 and rastm2 in Internet Relay Chat (irc)
/connect  irc.freenode.net Busness discussion: /join #biz 
ColorForth: /join #c4th #c4th-ot Forth: /join #retro #forth #concatenative
Programming: /join #python #lisp #scheme #asm

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com