Deutsch   English   Français   Italiano  
<2025Mar10.175516@mips.complang.tuwien.ac.at>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: An execution time puzzle
Date: Mon, 10 Mar 2025 16:55:16 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 55
Message-ID: <2025Mar10.175516@mips.complang.tuwien.ac.at>
References: <2025Mar10.083318@mips.complang.tuwien.ac.at> <2025Mar10.095420@mips.complang.tuwien.ac.at> <vqn2ro$1e8tr$1@dont-email.me>
Injection-Date: Mon, 10 Mar 2025 17:59:25 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9f8e121acd1049a94952a1c3822533e3";
	logging-data="1531760"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19eH6N7dNVHKnyaJl1QUNLj"
Cancel-Lock: sha1:mEk9LF37vyh9YOyzeSn58rfOdbo=
X-newsreader: xrn 10.11
Bytes: 2498

Brett <ggtgp@yahoo.com> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> I recreated this in assembly language:
>> 
>>         .text
>>         .globl main
>> main:
>>         mov $threaded, %rdx
>>         mov $0, %rbx
>>         mov $(returnstack+8),%r13
>>         mov %rdx, %r8
>> docol:   
>>         add    $0x8,%rbx
>>         sub    $0x8,%r13
>>         mov    %rbx,0x0(%r13)
>>         mov    %rdx,%rbx
>>         mov    (%rbx),%rax
>>         jmp    *%rax
>> outout:
>>         mov    %r8,%r15
>>         add    $0x10,%rbx
>>         mov    0x0(%r13),%rbx
>>         mov    -0x10(%r15),%rax
>>         mov    %r15,%rdx
>>         add    $0x8,%r13
>>         sub    $0x8,%rbx
>>         jmp    *%rax
>> 
>>         .data
>>         .quad docol
>>         .quad 0
>> threaded:
>>         .quad outout
>> returnstack:
>>         .zero 16,0
....
>How about giving us the original source code function, my x86 is rusty and
>it is helpful to plug source into compiler explorer to see what different
>compilers do.

The original source code is

: foo dup execute-exit ;
\ invoked with
' foo foo

This is Forth source code for Gforth (and the output is from
gforth-fast).  I expect that most c.a readers will find the assembly
language more approachable:-)

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>