Talk:Subleq
more eyes please
Just want to get some eyes on this and maybe a couple more implementations before releasing it.. Markjreed (talk) 01:34, 27 April 2015 (UTC)
Code points?
You mention code points and characters as well as giving character numbers. Should you just state that for this example use ASCII? --Paddy3118 (talk) 00:33, 28 April 2015 (UTC)
- My example uses ASCII; I'll add language to that effect. But there's no reason to limit the implementation to ASCII. One that handled arbitrary Unicode code points would still run it fine. An EBCDIC machine might have a problem with it.. Markjreed (talk) 00:55, 28 April 2015 (UTC)
- I've added a REXX example that handles both (within the same program), and is machine (ASCII or EBCDIC) agnostic. -- Gerard Schildberger (talk) 02:08, 14 November 2017 (UTC)
Promoting
Haven't seen any other complaints about the task, and we've got several implementations added, so I've promoted it out of draft status. Markjreed (talk) 17:51, 29 April 2015 (UTC)
Ada character input
I'm not an Ada programmer, but the Ada sample looks wrong to me. In the read input step it uses IIO.Get
to obtain the input, which I would have thought would read in an integer value, when it should just be reading a character. Is that a bug, or am I mistaken?
--j4_james (talk) 22:30, 22 September 2015 (UTC)
- You appear to be correct. I've added an incomplete marker to the entry with a description of the problem. Thanks. --Markjreed (talk) 22:45, 22 September 2015 (UTC)
Input File
Is the input file required to be a text file? Out of convenience, my interpreter reads binary files directly into memory. By modifying the "assembly" syntax just a little, I can get the assemblers Nasm, Fasm, and Uasm to assemble the text files to binary files. Gas probably can, too. The syntax is a little different and I haven't tried yet.
~$ cat hello00.subleq %define subleq(a, b, c) db a, b, c %define dat db start: subleq(zero, message, -1) ; subtract 0 from next character value to print ; terminate if it's <= 0 subleq(message, -1, -1) ; output character subleq(neg1, start+1, -1) ; modify above two instructions subtracting -1 subleq(neg1, start+3, -1) ; (adding 1) to their target addresses subleq(zero, zero, start) ; if 0-0 <= 0 (always) goto start ;useful constants zero: dat 0 neg1: dat -1 ;the message to print message: dat `Hello, World!\n\0` ~$ nasm hello00.subleq -o hello00.sub ~$ hexdump -C hello00.sub 00000000 0f 11 ff 11 ff ff 10 01 ff 10 03 ff 0f 0f 00 00 |................| 00000010 ff 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 0a 00 |.Hello, World!..| 00000020 ~$ ./subleq hello00.sub Hello, World! ~$
How cool is that? Well, if a binary input file is acceptable, I'll share my interpreter. There are some improvements, I'd like to make such as allocating memory in stack space. It's an 8 bit interpreter so there's that. I think I should be able to write a 64 bit interpreter and maybe even a floating-point interpreter.Superstitionfreeblog (talk) 07:05, 19 October 2024 (UTC)