Sujet : Re: An execution time puzzle
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.archDate : 10. Mar 2025, 17:55:16
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Mar10.175516@mips.complang.tuwien.ac.at>
References : 1 2 3
User-Agent : xrn 10.11
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>