Author Topic: nAssembler - Nspire on-calc assembler  (Read 34398 times)

0 Members and 1 Guest are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
nAssembler - Nspire on-calc assembler
« on: March 11, 2015, 01:41:14 pm »
As the title suggests, this is an on-calc assembler for the Nspire :)
It's written in python, so you need micropython on your calc.
All instructions I'm aware of are supported (except CDP, LDC, STC. They are useless on the Nspire)
What's still missing are some pseudoinstructions which don't add functionality but make your life easier,
like for example automatically creating x when you write LDR R0, =x
There is also no linker or anything which means that programs are just translated to binary in the order
they are written and the first line is also the entry point.
Read the readme in the spoiler below for more details on the assembly language syntax used or look at the example.


Please report bugs, missing instructions and feature suggestions.
The code is available at https://github.com/lkjcalc/nAssembler

Download from tiplanet archives: https://tiplanet.org/forum/archives_voir.php?id=821835


Spoiler For Readme:
Usage
-----
Install micropython on your calc.
Launch the nassembler.py.tns file using micropython.
The program will ask you to specify the input file (containing the assembly source code)
and the output file (where the binary will be stored).
You have to specify the full path (for example /documents/test/clrscr.asm.tns)
If there are no errors, micropython will now tell you "Press any key to exit".
You should now see the output file after refreshing the docbrowser
(just go to the homescreen and back to the docbrowser).

Assembly language
-----------------
(Also look at the examples)
IMPORTANT (syntax is not very flexible at the moment):
-Instruction names must be preceded by whitespace
-Labels must not be preceded by any whitespace
-The instruction names and syntax are like in standard ARM assembly
(like in the official ARM online documentation)
-No automatic substitution of e.g. MVN for MOV if the immediate value can only be encoded in the inverted case
-Two operands were three are required is not allowed (no implicit destination register), e.g. "ADD r0,#28" must be written out as "ADD r0,r0,#28"

All usual instructions are supported:
ADC(S), ADD(S), AND(S), B, BIC(S), BL, BX, CLZ, CMP, CMN,
EOR(S), LDM.., LDR(B/T/BT/H/SH/SB), MCR, MLA(S), MOV(S),
MRC, MRS, MSR, MUL(S), MVN(S), ORR(S),
RSB(S), RSC(S), SBC(S), SMLAL(S), SMULL(S), STM..,
STR(B/T/BT/H), SUB(S), SVC/SWI, SWP(B), TEQ, TST, UMLAL(S), UMULL(S)

The DCD, DCDU, DCW, DCWU, DCB and ALIGN directives are supported.

The ADR pseudo instruction is now also implemented.

Some other pseudo instruction (like PUSH etc) are not implemented.
Other instructions may be missing (report if you need one).

The first line of the source is also the entry point of the program.

Numeric literals:
Prefix with 0x for hexadecimal numbers, 0 for octal, 0b for binary.
Single characters enclosed in single quotes ' are interpreted as their ascii value
You can use DCB "some string" to create a string.

Feature suggestions/Bug reports
--------------------------------------------
Here or in the following places:
Topic on tiplanet: https://tiplanet.org/forum/viewtopic.php?t=16174&p=178789
Code on github: https://github.com/lkjcalc/nAssembler
« Last Edit: March 04, 2017, 05:22:52 am by lkj »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nAssembler - Nspire on-calc assembler
« Reply #1 on: March 11, 2015, 04:59:10 pm »
Damn that's awesome ! :D Many people have been wanting that to happen. Congratulations for making it happen !

Offline Harry5862

  • LV2 Member (Next: 40)
  • **
  • Posts: 37
  • Rating: +0/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #2 on: March 13, 2015, 11:23:47 am »
I cant open nAssembler.
I have installed Ndless 3.6 and nAssembler in the same directory as micropython.
Why??
Any suggestion?
Sorry if there are any mistakes.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #3 on: March 13, 2015, 04:04:37 pm »
Have you opened micropython at least once before opening nAssembler?
Did you rename one of the files?

Offline Harry5862

  • LV2 Member (Next: 40)
  • **
  • Posts: 37
  • Rating: +0/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #4 on: March 14, 2015, 02:47:58 am »
no ,what should I type in then.
If I run micropython I cant exit?
And if I run nAssembler it just Show a blackscreen for 1 sec and then go back to the normal Screen.
BTW:CX CAS HW-J
Sorry if there are any mistakes.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #5 on: March 14, 2015, 08:14:55 am »
You should just open it once and quit again.
Maybe your micropython is older than the one I used to test it. In the version I use you can exit by pressing the  ESC key.
Can you try it again with the version at https://tiplanet.org/forum/archives_voir.php?id=89439?

Offline Harry5862

  • LV2 Member (Next: 40)
  • **
  • Posts: 37
  • Rating: +0/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #6 on: March 14, 2015, 02:26:52 pm »
Ok it creates the file but I cant see the file in the normal file browser.
In Ndless Commander I can see the file but cant run it?
Sorry if there are any mistakes.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #7 on: March 14, 2015, 04:38:19 pm »
You should always append ".tns" to the name or it won't show up in the normal file browser. I'm not sure you can run programs in Ndless Commander?

Offline Harry5862

  • LV2 Member (Next: 40)
  • **
  • Posts: 37
  • Rating: +0/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #8 on: March 15, 2015, 04:19:28 am »
OK now it works
I must leave the file browser and reload it. :banghead:
thx lkj
Sorry if there are any mistakes.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #9 on: March 15, 2015, 02:42:51 pm »
I'm glad it works now :)

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #10 on: January 23, 2017, 07:53:18 am »
When do you post a new update?

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #11 on: January 23, 2017, 04:45:54 pm »
I didn't know anyone ever used this, so I didn't continue work on it  :P
What useful features are missing in your opinion?

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #12 on: February 02, 2017, 04:12:45 am »
Do you think that's possible to make a C compiler, in ARM, then compile the new code with nAssembly?

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #13 on: February 02, 2017, 07:54:22 am »
Writing a new compiler for C, in assembly, would be a huge project. I don't think it's realistically possible.
Porting some existing compiler would be easier, but may still be hard.

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Re: nAssembler - Nspire on-calc assembler
« Reply #14 on: February 02, 2017, 07:58:51 am »
Yes, it is a huge project, but a good project ;)