From 0de757b72c7510c6a1730fd1b6e4c3700eded79d Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Sun, 10 Jan 2021 19:21:14 +0900 Subject: [PATCH] Add uless to python version --- others/planck.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/others/planck.py b/others/planck.py index dee33aa..2f23d0e 100644 --- a/others/planck.py +++ b/others/planck.py @@ -6,6 +6,8 @@ import os import sys import operator +import array +import ctypes IMPLEMENTATION = "Python 3.x" MEMORY_SIZE = 0x20000 @@ -14,7 +16,7 @@ RSTACK_SIZE = 0x400 HERE_CELL = 0 LATEST_CELL = 4 -memory = [0]*(MEMORY_SIZE>>2) +memory = array.array('l', [0]*(MEMORY_SIZE>>2)) sp = MEMORY_SIZE>>2 rp = (MEMORY_SIZE - STACK_SIZE)>>2 @@ -224,6 +226,11 @@ add_binary_operator('|', operator.or_) add_binary_operator('^', operator.xor) add_binary_operator('<', operator.lt) add_binary_operator('=', operator.eq) +def uless(): + b = ctypes.c_ulong(pop()).value + a = ctypes.c_ulong(pop()).value + push(a < b) +add_simple_operator('u', uless) def argv(): push(ARGV_ADDR) push(len(sys.argv))