From 41dd00295db435efb6cbe96ed2f125b812a6e1e4 Mon Sep 17 00:00:00 2001 From: Matthias Simon Date: Wed, 17 Jul 2024 10:31:43 +0200 Subject: [PATCH] Add DUP instruction --- k3/t3xf/opcode/opcode_gen.go | 20 +++++++++++++++++++- k3/t3xf/opcode/opcodes.yml | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/k3/t3xf/opcode/opcode_gen.go b/k3/t3xf/opcode/opcode_gen.go index f84116ab..b7f2a776 100644 --- a/k3/t3xf/opcode/opcode_gen.go +++ b/k3/t3xf/opcode/opcode_gen.go @@ -1,5 +1,5 @@ // Code generated from opcode.tmpl.go and by 'go generate'; DO NOT EDIT. -// This file was generated by robots at 2024-07-17 08:44:51.337834819 +0200 CEST m=+0.920867588 +// This file was generated by robots at 2024-07-17 10:29:49.521237834 +0200 CEST m=+0.327002390 // Package opcode defines the opcodes used in T3XF. package opcode @@ -570,6 +570,12 @@ const ( // DROP Opcode = 0x00a3 + // Duplicate the item at the top of the stack. + // + // [obj] DUP [obj obj] + // + DUP Opcode = 0x00b3 + // Create an alternative for an enclosing alt operation that is // immediately successful. Block blk contains the code to execute // if this alternative is chosen by the containing alt. @@ -3193,6 +3199,16 @@ var Descriptions = map[Opcode]*Descriptor{ }, }, + DUP: { + Opcode: 0x00b3, + Description: "Duplicate the item at the top of the stack.\n\n", + Context: []string{"vm"}, + Operations: Operation{ + Pre: []string{"obj"}, + Post: []string{"obj", "obj"}, + }, + }, + ELSE: { Opcode: 0x03a3, Description: "Create an alternative for an enclosing alt operation that is\nimmediately successful. Block blk contains the code to execute\nif this alternative is chosen by the containing alt.\n\n", @@ -5786,6 +5802,7 @@ var opcodeStrings = map[Opcode]string{ DONEA: "donea", DOWHILE: "dowhile", DROP: "drop", + DUP: "dup", ELSE: "else", ENCODE: "encode", ENCODEO: "encodeo", @@ -6121,6 +6138,7 @@ var opcodeNames = map[string]Opcode{ "donea": DONEA, "dowhile": DOWHILE, "drop": DROP, + "dup": DUP, "else": ELSE, "encode": ENCODE, "encodeo": ENCODEO, diff --git a/k3/t3xf/opcode/opcodes.yml b/k3/t3xf/opcode/opcodes.yml index bddb5973..7c041bb6 100644 --- a/k3/t3xf/opcode/opcodes.yml +++ b/k3/t3xf/opcode/opcodes.yml @@ -861,6 +861,16 @@ drop: description: |+ Remove the item at the top of the stack and discard it. +dup: + opcode: 11 + context: + - vm + operations: + pre: [obj] + post: [obj, obj] + description: |+ + Duplicate the item at the top of the stack. + else: opcode: 58 context: