-
Notifications
You must be signed in to change notification settings - Fork 0
Support for JMS and JIND instructions #31
Comments
The JMS instruction is currently implemented as CALL. Although I could not figure out how the processor (in the given examples) knows when to exit the subroutine (as there seems to be missing a return instruction). Currently the jump mechanism is implemented by a lookup of the jump label in the current environment.
Fixing the JMP to allow numerical values as the parameter would yield simple implementations of JMI, JMS and JIND. Note: without the ability to jump to addresses a JIND instruction would be pretty pointless, as obviously |
How would you like the index to work? B) If the index is n it indicates that the instruction is the n-th instruction in the file. |
What the simulator should do is mimic exactly what the processor does, and when the MiMa starts running, it will execute code beginning from location 0 in RAM. Therefore indexing I haven't written an assembler myself yet, but I'd go for a two step approach; first generating a representation of the program and how it should appear in memory, and in a second step simulating the program. As for how to implement all the above, maybe have a look at cbdevnets assembler and simulator, I think it is one of the best performing MiMa simulators, but doesn't support MiMa X Maybe a small example helps, I'm using cbdevnets assembly syntax: Lets say we have this assembly program:
After resolving labels, the program in memory should look something like this and can be simulated:
I hope this helps a bit, but I still didn't really understand though why you need the scope system or how it works. Edit: corrected spelling |
The scope system allows multiple usages of the same label in one program, if they are inside different scopes. I'm already in the process of implementing the new instructions, but it still needs some more time.
|
Cool, so the scope System is quite nice. I got around that Problem by only generating unique label names, but scopes will make it easier for people to program in assembly, not having to do sth like "loop_1", "loop_2" and so on.
can be translated to a sequence of instructions that initialize Temp at runtime:
If you're interested how it's done for the MiMa, check https://github.com/mkiesinger/mimaFPGA#mima-specification
Function calls can be realized without using the CALL and RETURN instructions from the MiMa X. They are just there to make the call and return processes a bit faster, but the whole process is more than just using those two instructions, they are part of it. To implement function calls, you have to find a suitable caller-callee agreement. For example, caller pushes arguments on the stack, then return address, then actually executes the jump. The callee saves the register state on the stack, then doing some work, and when finished recreates the old register state, clears arguments and return address from the stack, pushes the return value on the stack and then jumps back to return address. For the caller it looks like the call never happened, and the arguments on the stack have been replaced with the returned value. Using the MiMa X instructions, maybe check the examples here, skip the math blabla http://gbi.ira.uka.de/vorlesungen/k-22-mima-x-folien.pdf |
Thank you vary much for the clarification. Support for JIND is now added 2cfee63 (new binaries follow). Instead there will be a separate tab for viewing the assembly of the current program. |
New binaries with the instruction are available here. |
More of a feature request :) Would it be possible to implement the JMS and JIND instructions mentioned in http://ti.ira.uka.de/Visualisierungen/Mima/mima-aufgaben.pdf?
The text was updated successfully, but these errors were encountered: