Author Topic: Mimas - an on-calculator assembly IDE  (Read 21818 times)

0 Members and 1 Guest are viewing this topic.

Offline ghest1138

  • LV2 Member (Next: 40)
  • **
  • Posts: 27
  • Rating: +0/-0
  • HueHueHue
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #15 on: January 24, 2013, 05:41:36 pm »
OMG!!!! This is so cool! Now I don't have to remember all the hexadecimal opcodes! (But first I need a link cable :3 )

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #16 on: January 25, 2013, 12:26:37 am »
No, Mimas is written for ZDS.
Well, it's written for tpasm, but it's more or less the same.
Quote
I don't think Mimas could build a 2-page app at once due to memory limitations. It also doesn't support directly writing to flash. It's certainly possible to build and sign apps on-calc, but he seems unlikely to implement such functionality since he seems to think screwing with flash is too dangerous.
No, I would merely say that it needs to be approached with appropriate caution.  A program that, one time in ten, crashes and wipes your RAM is annoying.  A program that, one time in a thousand, crashes and corrupts the OS, or your archived data, is intolerable.

I do hope to eventually support assembling Flash apps on the calculator - it could be implemented as a plugin, although that might be too slow.  The larger problem with using Mimas to assemble Mimas would be the need for macros (which I also intend to implement in the future.)  Also, I don't know how many symbols are used in Mimas - there may not be enough RAM for all of them. :P

I do like the idea of an assembly tutorial on calc.  It could certainly be done as an ebook, but maybe it could be more interactive than that?  I'm imagining an app that installs itself with a key hook so that, while you're writing your program, or hacking with Calcsys, or whatever, you could press a key to pop up the tutorial, read some more, then go back to what you were doing.  Something like Virtual Calc but much more lightweight.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Mimas - an on-calculator assembly IDE
« Reply #17 on: January 25, 2013, 02:41:54 am »
Now I don't have an excuse. Now I have to learn ASM.
If you like my work: why not give me an internet?








Offline GinDiamond

  • LV3 Member (Next: 100)
  • ***
  • Posts: 71
  • Rating: +2/-2
  • I dont always fail at life, but when I do, I dont
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #18 on: February 04, 2013, 03:46:21 pm »
#define wont work

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #19 on: February 04, 2013, 04:07:05 pm »
RTFM. It is not implemented yet.
Edit from the future : Sorry if I offended anyone. That's just how you get when you know the Minecraft community which tends to avoid reading /any/ doc and complains about it not working.
« Last Edit: February 19, 2013, 12:58:04 pm by Streetwalker »

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #20 on: February 04, 2013, 04:32:05 pm »
If you want to define a constant, the syntax is as follows:
Code: [Select]
symbol = valueThere is no macro support.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #21 on: February 04, 2013, 11:06:09 pm »
So, #define (as used in tasm/spasm) has two fundamentally different purposes:

- "Expression-like" macros:
Code: [Select]
    #define SUM(x,y) (x + y)
    #define PC ($)

- "Instruction-like" macros:
Code: [Select]
    #define CP_HL(reg) or a / sbc hl,reg / add hl,reg
    #define CRASH rst 00h

I probably won't implement the former type unless there is huge demand.  But as DrDnar points out, often macros of this sort are really just constants, and an equate would do equally well.  (I suppose it's also worth mentioning that since Mimas is a true multi-pass assembler, you can use equates in ways that wouldn't work in spasm or tasm.)


As far as instruction-like macros, I've thought quite a bit about them since I first started the project.  There are several ways that they could be implemented:

 - Call by value: arguments to a macro must be constant numeric expressions, which are evaluated before calling the macro.  This would be the easiest to implement but also very limited (registers can't be used as arguments; symbols used as args can't be modified; the behavior of PC, @B, and @F would be unlike the way macros are expected to work.)  Many folks would rightly say that this isn't really a macro.

 - Call by reference: arguments could be either constant expressions or literal symbols.  The bookkeeping gets a little bit more complicated than call-by-value; this would allow a macro to define symbols that are passed as arguments.

 - Call by name: arguments could be any expression not involving a register, and would be evaluated at the point in the macro where they're used (so PC would work the way you'd expect, and arguments that aren't used wouldn't be evaluated.)

 - Any of the above plus special support for registers: I could add special syntax that would let you choose a register by number.  For example, CP_HL above could be written as "OR A / SBC HL,R#(reg) / ADD HL,R#(reg)", and to call it you could write "CP_HL(\BC)" (note the backslash), or equivalently write "CP_HL(8)" (8 being the internal code for BC.)  (Obviously the exact syntax is up for debate.)

 - Call by syntactic substitution: arguments could be any valid expression (including registers), and would essentially be pasted into the syntax tree at the appropriate location.  This would require special syntax for parameter names (such as "SBC HL,{reg}") so that Mimas knows not to fully parse the instruction until compile time.  This would be a PITA to implement (especially if macros defined in one source file can be called from a different file, which I think is important to support.)

 - Call by textual substitution: take the text of the argument and paste it into the text of the macro, then parse the result.  This is, I think, less semantically "correct" than syntactic substitution (you lose symbol scoping) and possibly also a bit slower than the other options, but is arguably closest to the way tasm does it.  Like syntactic substitution, this would require special syntax for parameter names within the body of the macro.


Mostly unrelated to the above, I've also considered having macros use numbered parameters rather than named ones; e.g., you'd have to write CP_HL as "or a / sbc hl,#1 / add hl,#1" - sort of like function parameters in a shell script.  This would be considerably easier to implement than named parameters, plus would offer the possibility of variadic macros - the downside would be decreased readability.  In fact, the easiest way to implement this would be for all macros to be variadic, but then you lose error checking.

What do you folks think?  What do you typically use macros for, and how do you intuitively expect them to work?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #22 on: February 05, 2013, 06:30:43 am »
I personally like the last version that you presented. It loses readability, but I really think that that is okay with macro's. We can just describe what they do in a readme or something if it is really needed.

As well, I am not sure how you parse the files, but the way I have been doing it is to basically read the source as a type of program (I basically used ideas that I had already developed in Grammer+FileSyst). When a letter is concatenated with an opening parentheses, it tells the parser that it is a macro, so it searches the file for the macro and treats it as a "subroutine" of source code. This way you can add in some complicated macros for sure. I have been thinking of doing this for defining variables, too. It would really slow down compile times, but it would allow the user to define variables like String = "Hello" and then adding in a command like len(String) would make this easy:
Code: [Select]
     .db len(String),String
I have wished to be able to this quite often instead of needing to count the length of a string with PC math and labels.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Mimas - an on-calculator assembly IDE
« Reply #23 on: February 05, 2013, 03:24:44 pm »
Mostly unrelated to the above, did you released any documentation on writing plug-ins for Mimas ? I dig through all the files included in TiCalc's mimas-0.4.zip and found many docs on how to use them, install them etc but nothing about how to create one D:

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #24 on: February 05, 2013, 09:59:06 pm »
Mostly unrelated to the above, did you released any documentation on writing plug-ins for Mimas ? I dig through all the files included in TiCalc's mimas-0.4.zip and found many docs on how to use them, install them etc but nothing about how to create one D:
He expects you to dig through to the source code and base your plugin on the example provided. This is an attitude common in Unix/Linux culture.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Mimas - an on-calculator assembly IDE
« Reply #25 on: February 06, 2013, 02:47:37 am »
But I'm not good enough in ASM to understand how a system works from a code :(

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #26 on: February 08, 2013, 11:27:37 pm »
It's great that you're interested in writing a new plugin!  What do you want it to do?

It's true that all the documentation is in the code.  The documentation of individual routines is extensive (and where should it go but in the code?)  What I haven't written, and probably should, is a high-level "introductory guide to hacking Mimas" - doing that hasn't been a priority.  I am, of course, always willing to answer any questions you have.

As far as the actual process of writing a plugin - first of all, there aren't any general-purpose hooks that new plugins could attach themselves to.  You could write a new plugin and build it against Mimas 0.4, but it wouldn't do anything.  So to create a new plugin, you'll first need to figure out where in the app those hooks need to be added.  You'll need to decide on the inputs and outputs for the plugin.  Assign it a plugin ID in defs.inc.  Depending on what the plugin does, it's likely that you'll want to call Mimas routines that aren't part of the current API - to do that, add them to plugapi.dat.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Mimas - an on-calculator assembly IDE
« Reply #27 on: February 09, 2013, 04:16:46 am »
So I think writing a plugin requires modifying and recompiling Mimas ? If so, it doesn't make plugins portable :/

And I wanted to write a plugin to add to the parser CHIP-8 pseudo-assembly mnemonics, I wonder if that's possible.
« Last Edit: February 09, 2013, 04:17:19 am by Matrefeytontias »

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #28 on: February 10, 2013, 10:47:35 pm »
I think what Flop is getting at is that he is still working on the plug-in API; it hasn't really be finalized. He encourages you to add hooks, which may be incorporated into the official releases.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Mimas - an on-calculator assembly IDE
« Reply #29 on: February 10, 2013, 11:44:02 pm »
Right, well, there isn't a fixed ABI partly because the plugin feature is new and experimental, but also because a fixed ABI would require some space to store a table of addresses.  The same goes for hooks: it would be nice to have a system of hooks whereby plugins could register their interest in various sorts of events - but implementing that would take up valuable space.

I'm not really familiar with CHIP-8.  Are you saying you want to be able to generate CHIP-8 bytecode, or that you want to use CHIP-8 mnemonics and have them compiled into Z80 machine code?  Either way it is definitely possible.  Here's what needs to be done to define a new instruction type:

 - Choose a bytecode format.  Special instructions consist of a 7-bit ID (23 of which are currently defined) and up to 62 bytes of argument data.  The arguments can either be expressions or raw binary data (indicated by bit 7 of the ID byte.)
 - Write a routine to parse text into a bytecode instruction.
 - Write a routine to format a bytecode instruction as text.
 - Write a routine to assemble a bytecode instruction.
 - Optional but recommended: also patch asmto8xv and 8xvtoasm :)

So this would require three calls to the plugin: one in ParseInstruction, one in FormatInstruction, and one in AssembleProgramInstr.