gforth
[Top][All Lists]
Advanced

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

Re: Branches in AMD64 assembler


From: David Kuehling
Subject: Re: Branches in AMD64 assembler
Date: Sun, 16 Aug 2020 16:28:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

>>>>> "anthony" == anthony  <a@gc5.uk> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]