Deutsch   English   Français   Italiano  
<34df278ef0a52d0eab9d035f45795389@www.novabbs.com>

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

Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: zbigniew2011@gmail.com (LIT)
Newsgroups: comp.lang.forth
Subject: Re: Stack vs stackless operation
Date: Tue, 25 Feb 2025 21:08:36 +0000
Organization: novaBBS
Message-ID: <34df278ef0a52d0eab9d035f45795389@www.novabbs.com>
References: <591e7bf58ebb1f90bd34fba20c730b83@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
	logging-data="1773827"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="ovTHZ/VLht/KDF1nKqB7PmGhjiyfUdv/DKd8kGKFjRY";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: 8e58c9b6d1da98b6162b84d03d2307a6516add15
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$ejBxh.AHwFcz6vWqCPk4LOJspE77vUK/mGvy4O8SiAb8b5zyiSru6
Bytes: 2073
Lines: 62

So I did some quite basic testing with x86
fig-Forth for DOS. I devised 4 OOS words:

:=: (exchange values among two variables)
pop  BX
pop  DI
mov  AX,[BX]
xchg AX,[DI]
mov  [BX],AX
jmp  NEXT

++  (increment variable by one)
pop  BX
inc  WORD PTR [BX}
jmp  NEXT

-- (similar to above, just uses dec -- not tested, it'll give same
result)

+> (add two variables then store result into third one)
pop  DI
pop  BX
mov  CX,[BX]
pop  BX
mov  AX,[BX]
add  AX,CX
mov  [DI],AX
jmp  NEXT

How the simplistic tests have been done:

7 VARIABLE V1
8 VARIABLE V2
9 VARIABLE V3

: TOOK ( t1 t2 -- )
  DROP SPLIT TIME@ DROP SPLIT
  ROT SWAP - CR ." It took " U. ." seconds and "
  - 10 * U. ." milliseconds "
;

: TEST1
  1000 0 DO  10000 0 DO
  ...expression...
  LOOP LOOP
;

0 0 TIME! TIME@ TEST TOOK

The results are (for the following expressions):

V1 @ V2 @ + V3 !  - 25s 430ms
V1 V2 V3 +>       - 17s 240ms

1 V1 +!           - 14s  60ms
V1 ++             - 10s 820ms

V1 @ V3 ! V2 @ V1 ! V3 @ V2 ! - 40s 150ms
V1 V2 :=:                     - 15s 260ms

So there is a noticeable difference indeed.

--