Shop OBEX P1 Docs P2 Docs Learn Events
3rd and 4th stack operations — Parallax Forums

3rd and 4th stack operations

bigtreemanbigtreeman Posts: 32
edited 2021-09-22 06:24 in Forth

I would like to use 3rd,
but have gone with >r over r> swap

3rd seems to leave a 3 on the stack
4th seems to leave a 4 on the stack
over works as expected
same result in rom taqoz V1.1--v33h 190219-1900

TAQOZ# .s --- 
 DATA STACK (5)
1   $0000_0009   9
2   $0000_0008   8
3   $0000_0007   7
4   $0000_0006   6
5   $0000_0005   5 ok
TAQOZ# 3rd ---  ok
TAQOZ# .s --- 
 DATA STACK (6)
1   $0000_0003   3
2   $0000_0009   9
3   $0000_0008   8
4   $0000_0007   7
5   $0000_0006   6
6   $0000_0005   5 ok
TAQOZ# . --- 3  ok
TAQOZ# 4th ---  ok
TAQOZ# .s --- 
 DATA STACK (6)
1   $0000_0004   4
2   $0000_0009   9
3   $0000_0008   8
4   $0000_0007   7
5   $0000_0006   6
6   $0000_0005   5 ok
TAQOZ# 

in taqoz.spin2

OVER                mov     x,b             'read second data item and push
                jmp     #PUSHX

' 3RD ( n1 n2 n3 -- n1 n2 n3 n1 ) Copy the c item onto the stack
THIRD                   mov     x,c                 ' read third data item
                        jmp     #PUSHX

' 4TH ( n1 n2 n3 n4 -- n1 n2 n3 n4 n1 ) Copy the 4th item onto the stack - 48cy
FOURTH              mov     x,d
                        jmp     #PUSHX

Comments

  • MaciekMaciek Posts: 674
    edited 2021-09-22 06:57

    Strange. In Tachyon both work as expected.

    One thing to consider is the fact that TAQOZ is case sensitive and there might already be 3rd and 4th defined (in the lowercase). If that happens, TAQOZ will use these instead of 3RD or 4TH, I think. Have you tried both versions ?

  • bigtreemanbigtreeman Posts: 32
    edited 2021-09-22 08:08

    UPPER CASE thank you

    TAQOZ# .s --- 
     DATA STACK (0) ok
    TAQOZ# 5 ---  ok
    TAQOZ# 6 ---  ok
    TAQOZ# 7 ---  ok
    TAQOZ# 8 ---  ok
    TAQOZ# 9 ---  ok
    TAQOZ# 3RD ---  ok
    TAQOZ# .S --- 
     DATA STACK (6)
    1   $0000_0007   7
    2   $0000_0009   9
    3   $0000_0008   8
    4   $0000_0007   7
    5   $0000_0006   6
    6   $0000_0005   5 ok
    TAQOZ# . --- 7 ok
    TAQOZ# 4TH ---  ok
    TAQOZ# .S --- 
     DATA STACK (6)
    1   $0000_0006   6
    2   $0000_0009   9
    3   $0000_0008   8
    4   $0000_0007   7
    5   $0000_0006   6
    6   $0000_0005   5 ok
    TAQOZ#
    
Sign In or Register to comment.