ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:21:11 PM |
|
|
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
 |
February 04, 2014, 11:21:46 PM |
|
I think I win contest  Subtract and branch if less than or equal to zero[edit] The subleq instruction ("SUbtract and Branch if Less than or EQual to zero") subtracts the contents at address a from the contents at address b, stores the result at address b, and then, if the result is not positive, transfers control to address c (if the result is positive, execution proceeds to the next instruction in sequence).[3]:4-7 Pseudocode: subleq a, b, c ; Mem = Mem - Mem[a] ; if (Mem ≤ 0) goto c Conditional branching can be suppressed by setting the third operand equal to the address of the next instruction in sequence. If the third operand is not written, this suppression is implied. A variant is also possible with two operands and an internal accumulator, where the accumulator is subtracted from the memory location specified by the first operand. The result is stored in both the accumulator and the memory location, and the second operand specifies the branch address: subleq2 a, b ; Mem[a] = Mem[a] - ACCUM ; ACCUM = Mem[a] ; if (Mem[a] ≤ 0) goto b Although this uses only two (instead of three) operands per instruction, correspondingly more instructions are then needed to effect various logical operations. Synthesized instructions[edit] It is possible to synthesize many types of higher-order instructions using only the subleq instruction.[3]:9-10 Unconditional branch: JMP c == subleq Z, Z, c Addition can be performed by repeated subtraction, with no conditional branching; e.g., the following instructions result in the content at location a being added to the content at location b: ADD a, b == subleq a, Z subleq Z, b subleq Z, Z The first instruction subtracts the content at location a from the content at location Z (which is 0) and stores the result (which is the negative of the content at a) in location Z. The second instruction subtracts this result from b, storing in b this difference (which is now the sum of the contents originally at a and b); the third instruction restores the value 0 to Z. A copy instruction can be implemented similarly; e.g., the following instructions result in the content at location b getting replaced by the content at location a, again assuming the content at location Z is maintained as 0: MOV a, b == subleq b, b subleq a, Z subleq Z, b subleq Z, Z Any desired arithmetic test can be built. For example, a branch-if-zero condition can be assembled from the following instructions: BEQ b, c == subleq b, Z, L1 subleq Z, Z, OUT L1: subleq Z, Z subleq Z, b, c OUT: ... Subleq2 can also be used to synthesize higher-order instructions, although it generally requires more operations for a given task. For example no fewer than 10 subleq2 instructions are required to flip all the bits in a given byte: NOT a == subleq2 tmp ; tmp = 0 (tmp = temporary register) subleq2 tmp subleq2 minus_one ; acc = -1 subleq2 a ; a' = a + 1 subleq2 Z ; Z = - a - 1 subleq2 tmp ; tmp = a + 1 subleq2 a ; a' = 0 subleq2 tmp ; load tmp into acc subleq2 a ; a' = - a - 1 ( = ~a ) subleq2 Z ; set Z back to 0
|
|
|
|
bitcoinpaul
|
 |
February 04, 2014, 11:22:11 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.

|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:24:04 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
Congrats!
|
|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:25:37 PM |
|
I think I win contest  Yah, yah....
|
|
|
|
xyzzyx
Sr. Member
  
Offline
Activity: 490
Merit: 250
I don't really come from outer space.
|
 |
February 04, 2014, 11:26:00 PM |
|
Very good if it's 28, coz I know only a solution with 32 opcodes.
It's actually more, but immediate-mode and register-to-register operations use a symmetry in opcode encoding to use the same dispatch code in the switch (case) statement. This was done on purpose to make the VM more compact. You have move register-register and move immediate, for example that use the same dispatch code. These ops use the same dispatch code: move (MOV, MOVI), move 1's complement (MVN, MVNI), add (ADD, ADDI), subtract (SUB, SUBI), multiply (MUL, MULI), divide (DIV, DIVI), modulus (MOD, MODI), compare (CMP, CMPI). There are several ops which we don't need. For example, there is an op to read an integer from the Oberon text stream. We have no use for that. Although, these could be re-purposed for blockchain I/O instead.
|
"An awful lot of code is being written ... in languages that aren't very good by people who don't know what they're doing." -- Barbara Liskov
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
 |
February 04, 2014, 11:27:04 PM |
|
Below is a "Hello world" program adapted from Lawrence Woodman helloworld.sq [10]. It is exceptionally terse, but is a good example of Subleq efficiency. L:H (-1); U L; U ?+2; Z H (-1); Z Z L . U:-1 H:"hello, world\n" Z:0 A special variable called Z is often used in Subleq as an intermediate temporary variable within a highly small scope. It is commonly assumed that this variable is initialised at zero and left at zero after every usage. The program above consists of five instructions. First instruction prints the character pointed by its first operand (the first pointer) which is initialised to the beginning of the data string – the letter ’h’. Second instruction increments that pointer – the first operand of the first instruction. Third instruction increments the second pointer, which is the second operand of the fourth instruction. Fourth instruction tests the value pointed by the second pointer and halts the program when the value is zero. It becomes zero when the pointer reaches the cell one after the end of the data string, which is Z:0. The fifth instruction loops back to the beginning
|
|
|
|
freigeist
|
 |
February 04, 2014, 11:27:58 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
 Does it still have the web client interface on http://localhost:7874 and https://localhost:7875 ?! What are the plans for the web client in future? Will be developed further on or will be removed from the distribution?
|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:30:18 PM |
|
Below is a "Hello world" program adapted from Lawrence Woodman helloworld.sq [10]. It is exceptionally terse, but is a good example of Subleq efficiency. L:H (-1); U L; U ?+2; Z H (-1); Z Z L . U:-1 H:"hello, world\n" Z:0 A special variable called Z is often used in Subleq as an intermediate temporary variable within a highly small scope. It is commonly assumed that this variable is initialised at zero and left at zero after every usage. The program above consists of five instructions. First instruction prints the character pointed by its first operand (the first pointer) which is initialised to the beginning of the data string – the letter ’h’. Second instruction increments that pointer – the first operand of the first instruction. Third instruction increments the second pointer, which is the second operand of the fourth instruction. Fourth instruction tests the value pointed by the second pointer and halts the program when the value is zero. It becomes zero when the pointer reaches the cell one after the end of the data string, which is Z:0. The fifth instruction loops back to the beginning Come on. It's academic. You have to do a lot more to do everyday operations.
|
|
|
|
xibeijan
Legendary
Offline
Activity: 1232
Merit: 1001
|
 |
February 04, 2014, 11:30:35 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
Magic! nice work.
|
|
|
|
msin
Legendary
Offline
Activity: 1512
Merit: 1006
|
 |
February 04, 2014, 11:30:58 PM |
|
While I commend you for your work, I am wondering what is this for specifically?
I thought we all agreed that coins and similar representations should not be a thing in NXT? NXTs logo is all we really need? Why do we need a geometric shape?
It's called, freedom to do whatever the fuck you want. And CFB asked for it, so please accept it.
|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:31:40 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
 Does it still have the web client interface on http://localhost:7874 and https://localhost:7875 ?! What are the plans for the web client in future? Will be developed further on or will be removed from the distribution? The plan: no NRC.
|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:33:15 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
Magic! nice work. No, computer science. 
|
|
|
|
xyzzyx
Sr. Member
  
Offline
Activity: 490
Merit: 250
I don't really come from outer space.
|
 |
February 04, 2014, 11:34:39 PM |
|
What are the plans for the web client in future? Will be developed further on or will be removed from the distribution?
The plan: no NRC. There's no stopping anyone from packaging the current web client as a stand-alone program, though. With the javascript Curve25519 implementation, it should be possible to sign transactions locally, too, and safely point the web client at a public node.
|
"An awful lot of code is being written ... in languages that aren't very good by people who don't know what they're doing." -- Barbara Liskov
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
 |
February 04, 2014, 11:34:58 PM |
|
Below is a "Hello world" program adapted from Lawrence Woodman helloworld.sq [10]. It is exceptionally terse, but is a good example of Subleq efficiency. L:H (-1); U L; U ?+2; Z H (-1); Z Z L . U:-1 H:"hello, world\n" Z:0 A special variable called Z is often used in Subleq as an intermediate temporary variable within a highly small scope. It is commonly assumed that this variable is initialised at zero and left at zero after every usage. The program above consists of five instructions. First instruction prints the character pointed by its first operand (the first pointer) which is initialised to the beginning of the data string – the letter ’h’. Second instruction increments that pointer – the first operand of the first instruction. Third instruction increments the second pointer, which is the second operand of the fourth instruction. Fourth instruction tests the value pointed by the second pointer and halts the program when the value is zero. It becomes zero when the pointer reaches the cell one after the end of the data string, which is Z:0. The fifth instruction loops back to the beginning Come on. It's academic. You have to do a lot more to do everyday operations. Check out http://da.vidr.cc/projects/subleq/Is it really just academic theoretical? They explain how they made C compiler in PDF, there is a chip that implements this I only know about this from when I found it, and not sure if it is usable, but if there is a C compiler for it, then it sure sounds usable to me. http://esolangs.org/wiki/Higher_Subleqhere is source to C compiler: http://mazonka.com/subleq/hsq.cppJames
|
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
 |
February 04, 2014, 11:37:48 PM |
|
Below is a "Hello world" program adapted from Lawrence Woodman helloworld.sq [10]. It is exceptionally terse, but is a good example of Subleq efficiency. L:H (-1); U L; U ?+2; Z H (-1); Z Z L . U:-1 H:"hello, world\n" Z:0 A special variable called Z is often used in Subleq as an intermediate temporary variable within a highly small scope. It is commonly assumed that this variable is initialised at zero and left at zero after every usage. The program above consists of five instructions. First instruction prints the character pointed by its first operand (the first pointer) which is initialised to the beginning of the data string – the letter ’h’. Second instruction increments that pointer – the first operand of the first instruction. Third instruction increments the second pointer, which is the second operand of the fourth instruction. Fourth instruction tests the value pointed by the second pointer and halts the program when the value is zero. It becomes zero when the pointer reaches the cell one after the end of the data string, which is Z:0. The fifth instruction loops back to the beginning Come on. It's academic. You have to do a lot more to do everyday operations. Libraries/Demo Libraries for programs written in SUBLEQ assembly, as accepted by sqasm, are available. They provide several common functions: getint (read integer from input) gets (read string from input) putint (write integer to output) puts (write string to output) Several useful procedures are also available: bubblesort (sort a string of characters) calc (perform a given operation on two integers) factorial (calculate the factorial of a positive integer) primes (generate and print a list of primes) Usage information and equivalent C code (where appropriate) is provided in the comments of each of these files. A menu-driven program demonstrating the above libraries is also provided. Simply call make run in the project root directory to run the demo program. Interpreter A very minimal (only 222 bytes in size) SUBLEQ interpreter written in C is available: _____________ What everyday operations do you have in mind?
|
|
|
|
msin
Legendary
Offline
Activity: 1512
Merit: 1006
|
 |
February 04, 2014, 11:38:23 PM |
|
In the meantime, I wish to report that 0.7.0 is running successfully with an H2 database backend, no more serialized java object files. No need to keep all blocks and transactions in memory anymore.
Magic! nice work. No, computer science.  I'm starting to like ChuckOne.
|
|
|
|
jl777
Legendary
Offline
Activity: 1176
Merit: 1134
|
 |
February 04, 2014, 11:40:15 PM |
|
CfB, what is your opinion of subleq? It seems we just need to implement one opcode.
There already exists Higher_subleq (assembly language) and C compiler, so that sure sounds like the quickest path. The CPU model they use doesn't seem too crazy.
James
|
|
|
|
ChuckOne
Sr. Member
  
Offline
Activity: 364
Merit: 250
☕ NXT-4BTE-8Y4K-CDS2-6TB82
|
 |
February 04, 2014, 11:42:44 PM |
|
Below is a "Hello world" program adapted from Lawrence Woodman helloworld.sq [10]. It is exceptionally terse, but is a good example of Subleq efficiency. L:H (-1); U L; U ?+2; Z H (-1); Z Z L . U:-1 H:"hello, world\n" Z:0 A special variable called Z is often used in Subleq as an intermediate temporary variable within a highly small scope. It is commonly assumed that this variable is initialised at zero and left at zero after every usage. The program above consists of five instructions. First instruction prints the character pointed by its first operand (the first pointer) which is initialised to the beginning of the data string – the letter ’h’. Second instruction increments that pointer – the first operand of the first instruction. Third instruction increments the second pointer, which is the second operand of the fourth instruction. Fourth instruction tests the value pointed by the second pointer and halts the program when the value is zero. It becomes zero when the pointer reaches the cell one after the end of the data string, which is Z:0. The fifth instruction loops back to the beginning Come on. It's academic. You have to do a lot more to do everyday operations. Check out http://da.vidr.cc/projects/subleq/Is it really just academic theoretical? They explain how they made C compiler in PDF, there is a chip that implements this I only know about this from when I found it, and not sure if it is usable, but if there is a C compiler for it, then it sure sounds usable to me. http://esolangs.org/wiki/Higher_Subleqhere is source to C compiler: http://mazonka.com/subleq/hsq.cppJames That's the point in being turing complete, right? turing-complete = you can calculate whatever is computable. So, C is turing complete and subleq is turing complete. That is, they are equivalent: there is a C program for every subleq program that delivers the very same output for the very same input and vice-versa. But anyway, I would always go with proven technology. I mean C and subleq are just ideas/standards/concepts. There are many, many compilers/programs/bits'n'bytes for them. There is where the problem occurs not on the paper but in the source code. There are the bugs and optimization potentials. Therefore: use what's already there and has been proven itself in millions of devices for years.
|
|
|
|
|