[Joypy-announce] joypy/Joypy: 3 new changesets

Back to archive index
scmno****@osdn***** scmno****@osdn*****
Wed Nov 13 12:01:34 JST 2019


changeset 51ea892bff98 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=51ea892bff98
user: Simon Forman <sform****@hushm*****>
date: Tue Nov 12 11:42:24 2019 -0800
description: Refactor sub_base_merge_and_store.
changeset f1c6b09ad117 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=f1c6b09ad117
user: Simon Forman <sform****@hushm*****>
date: Tue Nov 12 15:47:33 2019 -0800
description: "new" word.
changeset 58d50e195941 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=58d50e195941
user: Simon Forman <sform****@hushm*****>
date: Tue Nov 12 16:09:13 2019 -0800
description: "swap" word.

diffstat:

 thun/asm-dump.txt       |   61 +++++++++++++++++++++++++++++++++++++++++++++++-
 thun/compiler.markII.pl |   60 ++++++++++++++++++++++++++++------------------
 thun/joy_asmii.bin      |  Bin 
 thun/markII.rst         |   30 +++++++++++++++++++++++
 4 files changed, 126 insertions(+), 25 deletions(-)

diffs (226 lines):

diff -r 3cb6b7b1a305 -r 58d50e195941 thun/asm-dump.txt
--- a/thun/asm-dump.txt	Tue Nov 12 09:23:31 2019 -0800
+++ b/thun/asm-dump.txt	Tue Nov 12 16:09:13 2019 -0800
@@ -5,7 +5,7 @@
 mov_imm(0, 0),
 store_word(0, 0, 0),
 mov_imm(0, 4096),
-mov_imm(1, I1),
+mov_imm(1, S1),
 mov_imm(2, 0),
 mov_imm(3, 0),
 store_word(2, 0, 0),
@@ -186,6 +186,65 @@
 store_word(6, 0, 0),
 do_offset(H),
 label(I1),
+symbol(I1),
+mov_imm(5, 0),
+do_offset(D),
+label(J1),
+symbol(J1),
+lsl_imm(6, 2, 2),
+asr_imm(6, 6, 17),
+eq_offset(K1),
+add(6, 6, 0),
+label(K1),
+lsl_imm(7, 2, 17),
+asr_imm(7, 7, 17),
+eq_offset(L1),
+add(7, 7, 0),
+label(L1),
+load_word(8, 7, 0),
+lsl_imm(9, 2, 2),
+asr_imm(9, 9, 17),
+eq_offset(M1),
+add(9, 9, 0),
+label(M1),
+lsl_imm(10, 2, 17),
+asr_imm(10, 10, 17),
+eq_offset(N1),
+add(10, 10, 0),
+label(N1),
+sub_imm(0, 0, 4),
+sub_imm(6, 6, 0),
+eq_offset(O1),
+sub(6, 6, 0),
+and_imm(6, 6, 32767),
+label(O1),
+sub_imm(10, 10, 0),
+eq_offset(P1),
+sub(10, 10, 0),
+and_imm(10, 10, 32767),
+label(P1),
+lsl_imm(6, 6, 15),
+ior(6, 6, 10),
+store_word(6, 0, 0),
+mov_imm(6, 4),
+sub_imm(0, 0, 4),
+sub_imm(9, 9, 0),
+eq_offset(Q1),
+sub(9, 9, 0),
+and_imm(9, 9, 32767),
+label(Q1),
+sub_imm(6, 6, 0),
+eq_offset(R1),
+sub(6, 6, 0),
+and_imm(6, 6, 32767),
+label(R1),
+lsl_imm(9, 9, 15),
+ior(9, 9, 6),
+store_word(9, 0, 0),
+do_offset(H),
+label(S1),
+expr_cell(I1, 4),
 expr_cell(R, 4),
+expr_cell(J1, 4),
 expr_cell(J, 4),
 expr_cell(S, 0)].
\ No newline at end of file
diff -r 3cb6b7b1a305 -r 58d50e195941 thun/compiler.markII.pl
--- a/thun/compiler.markII.pl	Tue Nov 12 09:23:31 2019 -0800
+++ b/thun/compiler.markII.pl	Tue Nov 12 16:09:13 2019 -0800
@@ -99,9 +99,7 @@
 
     % Build and write the new list cell.
     incr(SP),
-    sub_base_from_offset(TEMP2, SP),
-    sub_base_from_offset(TEMP0, SP),
-    merge_and_store(TEMP2, TEMP0, SP),
+    sub_base_merge_and_store(TEMP2, TEMP0, SP),
     incr(SP),
     sub_base_from_offset(TEMP3, SP),
     chain_link(TOS, TEMP3),
@@ -111,9 +109,7 @@
     head_addr(TOS, TermAddr),
     jump(PUSH),
 
-
     definition(I),  % ======================================
-
     unpack_pair(TOS, TEMP0, TOS, SP),
     % TEMP0 = Address of the quoted program.
     % TOS = Address of the stack tail.
@@ -129,18 +125,15 @@
             asm(mov(TEMP0, TEMP2)),  % update temp0 to point to rest of quoted program.
             incr(SP),  % We are about to write a cell.
             br(if_zero(TEMP2),
-                [  % TERM is the last item in the quoted program.
-                    % The expr should point to a cell that has TEMP1 head and tail
-                    % of the rest of the expression.
-                    sub_base_from_offset(TEMP1, SP),
-                    sub_base_from_offset(EXPR_addr, SP),
-                    merge_and_store(TEMP1, EXPR_addr, SP)
-                ], [  % TERM has at least one more item after it.
-                    % We know that we will be writing that item in a
-                    % cell immediately after this one, so it has TEMP1
-                    % head and 4 for the tail.
-                    merge_and_store(TEMP1, TEMP3, SP)
-                ]
+                [sub_base_merge_and_store(TEMP1, EXPR_addr, SP)],
+                % TERM is the last item in the quoted program.
+                % The expr should point to a cell that has TEMP1 head and tail
+                % of the rest of the expression.
+                [merge_and_store(TEMP1, TEMP3, SP)]
+                % TERM has at least one more item after it.
+                % We know that we will be writing that item in a
+                % cell immediately after this one, so it has TEMP1
+                % head and 4 for the tail.
             )
         ]),
         asm(mov(EXPR_addr, TEMP4))
@@ -151,19 +144,33 @@
     load(TEMP1, TOS),  % TEMP1 contains the record of the second stack cell.
     % write a new cell, the head is head of TEMP1, the tail is tail of TEMP1
     % but adjusted to offset from SP+4 where we are about to write this record.
-    % Load tos with ram[tos]
-    unpack_pair(TEMP1, TEMP0, TEMP1, TOS),
-    % TEMP0 = HeadAddr, TEMP1 = TailAddr
+    unpack_pair(TEMP1, TEMP0, TEMP1, TOS),  % TEMP0 = HeadAddr, TEMP1 = TailAddr
     incr(SP),
-    sub_base_from_offset(TEMP0, SP),
-    sub_base_from_offset(TEMP1, SP),
-    merge_and_store(TEMP0, TEMP1, SP),
+    sub_base_merge_and_store(TEMP0, TEMP1, SP),
     jump(Main),  % We already wrote the stack cell so 'Main' not 'Done'.
 
+    definition(New),  % ======================================
+    asm(mov_imm(TermAddr, 0)),  % Rely on push machinery.
+    jump(PUSH),
+
+    definition(Swap),  % ======================================
+    unpack_pair(TOS, TEMP0, TEMP1, SP),
+    % TEMP0 = Address of the first item on the stack.
+    % TEMP1 = Address of the stack tail.
+    load(TEMP2, TEMP1),  % TEMP1 contains the record of the second stack cell.
+    unpack_pair(TOS, TEMP3, TEMP4, SP),
+    % TEMP3 = Address of the second item on the stack.
+    % TEMP4 = Address of the stack tail.
+    incr(SP),
+    sub_base_merge_and_store(TEMP0, TEMP4, SP),  % Push first item onto stack.
+    asm(mov_imm(TEMP0, 4)),  % Used for linking to previous cell.
+    incr(SP),
+    sub_base_merge_and_store(TEMP3, TEMP0, SP),  % Push first item onto stack.
+    jump(Main),
 
     % ======================================
     label(Expression),
-    dexpr([Dup, Cons, I])
+    dexpr([New, Dup, Swap, Cons, I])
 ]).
 
 
@@ -260,6 +267,11 @@
         label(THEN), Then, label(END)
     ]).
 
+⟐(sub_base_merge_and_store(HeadAddr, TailAddr, Base)) -->
+    ⟐([sub_base_from_offset(HeadAddr, Base),
+    sub_base_from_offset(TailAddr, Base),
+    merge_and_store(HeadAddr, TailAddr, Base)]).
+
 
 /*
 The add_label/3 relation is a meta-logical construct that accepts a comparision
diff -r 3cb6b7b1a305 -r 58d50e195941 thun/joy_asmii.bin
Binary file thun/joy_asmii.bin has changed
diff -r 3cb6b7b1a305 -r 58d50e195941 thun/markII.rst
--- a/thun/markII.rst	Tue Nov 12 09:23:31 2019 -0800
+++ b/thun/markII.rst	Tue Nov 12 16:09:13 2019 -0800
@@ -377,6 +377,36 @@
     ],
     ヮ(i),
 
+
+------------------------------------------
+
+    [ヶ,ペ],ワ(new),
+
+    ヶ, low_half(TOS, SP)
+    ペ, write_cell(TOS,   SP)
+
+
+------------------------------------------
+
+
+    [ナ,ズ,セ,ネ,ヒ,ド,ャ,ペ],ワ(swap),
+
+    ナ, low_half(TEMP0, TOS)
+    ズ, deref(TEMP0)
+    セ, chop_word(TEMP1, TEMP0)
+    ネ, chop_word(TEMP2, TOS)
+    ヒ, or_inplace(TEMP0, TEMP2)
+    ド, write_cell(TEMP0, SP)
+    ャ, asm(ior(TOS, TEMP1, SP))
+    ペ, write_cell(TOS,   SP)
+
+
+
+
+
+
+
+
 PC == 0
 PC == 0x25
 


More information about the Joypy-announce mailing list
Back to archive index