Re: Branches in AMD64 assembler

anthony <[email protected]> Mon, 17 Aug 2020 10:56:48 +0100
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <[email protected]>
On 16/08/2020 15:28, David Kuehling wrote:
>>>>>> "anthony" == anthony  <[email protected]> writes:
>> Hello, after reading the gforth manual, the list archive and the
>> comp.lang.forth newsgroup I was unable to find any documentation or an
>> example with a loop in ASM64 and ABI-CODE.  I expected something like
>> this:
>> ABI-CODE TEST    0 # R10 MOV L1:   1 # R10 ADD   10 # R10 CMP    L1
>> REL)  JNZ   RET END-CODE
> I think, you most of Gforth's assemblers supply forth-like control flow
> words, to compile branches, using the stack to resolve forward/backwards
> branch references (no labels), i.e. write something like
>
>     BEGIN
>        ...
>        10 # R10 CMP
>     LE UNTIL
>
> Looking at amd64/asm.fs, I see that condition-codes are supported in
> "assembler" as well as "operator" syntax:
>
>    $10 cond: vs vc   u< u>=  0= 0<>  u<= u>   0< 0>=  ps pc   <  >=   <=  >
>    $10 cond: o  no   b  nb   z  nz   be  nbe  s  ns   pe po   l  nl   le  nle
>
> I.e. you could write '<= UNTIL'  as well as 'LE UNTIL'
>
> See also Gforth's manual or the amd64/asm.fs implementation:
>
> https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Common-Assembler.html
> https://git.savannah.gnu.org/cgit/gforth.git/tree/arch/amd64/asm.fs
>
> cheers,
>
> David

Hi David,

thanks for your reply, this was exactly the hint I needed to go further.
I will post a number of examples in a separate post for others with a 
similar question in the future.

Cheers, Anthony