Replies: 7 comments 53 replies
-
Hold on, It's going to be a long one 😺Cool work and ideas! After reading what you posted, I did some research last night to see what "syscalls" we would like to support. This comment is all about the different syscalls fj should support, and how. Are you familiar with linux's "Everything is a file" concept? I came to the conclusion that the current input-output mechanism could go very well with these kinds of files. I got to the next list. I find it important to keep in minimal as possible, and not support some OS concepts that can be implemented on flipjump itself. Flip jump IO interface
The files
So we'll get key presses with file 0, and color the screen with files 5/6. About the random - we can get the same functionality ourselves by getting only a 64bit seed, and calculating in fj the next random numbers. Yet, it does look simpler to just get one bit at a time, even though it might be a bit stronger. About FillRectangle - It kinda bothers me that it's not its simplest form ( I have thoughts about adding 2 more "Files" for setting pixels (which will be faster than the above-suggested options in some cases).
More FilesAlso, I thought about adding the next file-interfaces (as these statistics are easy to implement), but I'm not sure if they are necessary:
Actual FilesAt first, I thought that it might be cool to add support for file system operation (as open/close/create/delete files); But this kind of abstraction just magically gives us all that we want. SocketsAnother thing I think that might be supported is sockets, as communication can't be done with flipjump on its own (it can be treated as a new device, like the screen):
Reading and writing to sockets:
Reading/writing to a closed / not-defined-yet file descriptor will stop the program. Of course, all this sockets talk is cool but probably won't be in the near future, but I'd love to hear what you think about this subject. EOFWith using files this way, an end-of-file check should be supported.
I'd be happy to hear your thoughts. |
Beta Was this translation helpful? Give feedback.
-
Exactly. I think that we should use the terminology of "Devices" from now on. I liked your suggestion, and I have a few changes.
about the next, I'm not really sure why it is needed:
The 2/3 checks can be done as you suggested (jumping to 4w and reading from 5w). I think that the best way to put the Flush bit is in
About zeroing 3w and 5w - It is a change that the stl and many tests won't work without refactoring them. I don't think the refactoring should take much time, but we need to know that and update it so that Yet, it will be easier for newcomers, It's kinda more elegant, and it might save a few flipjump-opcode here and there.
Btw I just saw your pull request, nice job! |
Beta Was this translation helpful? Give feedback.
-
The new IO modelMain concepts:
It doesn't support a general flush command as discussed above, nor does it support interrupts. The IO model structureMemory Layout:
Some definitions:
General IO functionality: Flipping IO+0: outputs 0 Jumping to IO: fills the Both input and output might block until the device is ready (to yield an input or to get your output). The Device ManagerThis mode is used for connecting to new devices, switching between devices, and querying data about the devices.
At the start of each program, the current device will be 0x00, the standard IO. The Devices List:Device types are numbers from [0x01, 0xfe]. Standard IO [defaultly opened as device number 0x00. can't be opened or closed]: Broken IO [defaultly opened as device number 0xff. can't be opened or closed]: Keyboard [device type 0x01]: TextScreen [device type 0x02]:
Each one of GraphicScreen [device type 0x03]: 0x00 - 1bit black-white Then, communicates according to this protocol:
Each one of Optional - allow reading 4-bits at a time (hex-input) for a faster read. Future DevicesThe next devices don't need to be supported yet, but their concept is important. Network Interface Card [device type 0x04]: Hard Drive [device type 0x05]: Infinite Memory [device type 0x06]: Note that in this scheme, every device can open a new device (for example, a binding socket can create a socket for a new connection). That's part of the devices-model power. Throughout all this comment - if a program tries to execute a reserved op - simply fail and stop. Implementing the screenI did some basic research. It seems that a good way of implementing a screen is with Tkinter and Canvas. Now, about printing Text on a graphical screen. |
Beta Was this translation helpful? Give feedback.
-
so, my current proposal is basically to have a "vm.py" that can have devices plugged to it (it opens a TkInter window and can accept devices such as keyboard, "filesystem folder", ...) the biggest disadvantage for FJ is that it will only be able to control it using whole bytes (so the protocol can't be something that expects 3 bits, for example, as they'd need to get flushed).
yeah, it sucks to not have it because we can get blocked.. but oh well.. the protocol could have a way to signal that it's going to be busy
yeah, don't worry, it was just a prototype
yeah, I think that's good disclaimer: work is heavy lately and I'll probably only have 2-3 hours/week to sit down and write code (but I can spend a few minutes CR everyday) during next month |
Beta Was this translation helpful? Give feedback.
-
I'll try to make the first commit of a less hackish prototype today and ask for your opinion |
Beta Was this translation helpful? Give feedback.
-
for now, yes, but I think it can be extended to Windows using temporary files
cool!
yeah, I've done it in Python already and I'm doing it in brainfuck now by the way, I think I'll also try to implement a shell (well, at least with "ls" and "cat"; but it could also execute programs (./a.bf) if I manage to plug a BF interpreter (written in BF).. or later a FJ interpreter written in FJ :D |
Beta Was this translation helpful? Give feedback.
-
Hi @lestrozi ! would you be open now to integrate it with flipjump? I am much more open to that then I was before 😄 A flip-jump pong would be awesome. btw, I started thinking on a brainfuck -> flip-jump compiler, so when it'll be finished - we could take the brainfuck source you wrote and transform it into a flip-jump program. |
Beta Was this translation helpful? Give feedback.
-
Based on previous discussions (#148 and #152), I think it makes sense to start this one.
Here's a proposal to support Basic (but not so basic as currently) Input/Output (backwards compatible):
proposal 1
flip dw+2 (first time) - activates extended mode
this turns 4dw, 5dw, 6dw and 7dw into "registers" (let's say: a, b, c, d)
then we can set values on those registers and flipping dw+n (n>2) is like calling "int n", which will perform an IO operation
for example:
a=0, b=65, c=?, d=? + flip [dw+3] -> prints b ('A')
a=1, b=? , c=?, d=? + flip [dw+3] -> sets b as 0x80 if there's input waiting or 0x00 otherwise (the current input reading could be used for reading bits)
If this works, I suppose we could start thinking about the graphical IO calls later
proposal 2
very similar to 1, but the "trigger" that causes the interrupt could be jumping to [4dw] (so you need to set the return addr in 4dw+w first) instead of just flipping dw+n
this would allow 4 different interrupts (you could also jump to 5dw, 6dw and 7dw)
EDIT: scratch that, it doesn't work if the interrupt returns a value into a register since you'd need to jump to it to read the value and you don't want to run the interruption again
Curious about your thoughts on that.
Beta Was this translation helpful? Give feedback.
All reactions