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

0 Members and 1 Guest are viewing this topic.

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #15 on: February 27, 2017, 11:17:22 am »
Hi ikj,
may be there are some things missing, that only few people shows interest to your assembler.
Some points:
-installing should be easy. In the text file its explained, but not every beginner is able to work with it. A step by step describing would be better and it should content every step, also installing ndless and microphyton and pyWrite or another editor. Should folders me made? Which and where? For example, it's not clear in the beginning, that files have to be put in an ndless folder at root.
Am using a nspire cx cas,
using os 4.4,
installed ndless 4.4,
started micropython (134/146) one time, as its told,
started nassembler but get error abour file format not supported.
May be that and the not so clear installation info hinders some interested people to try it.
Some simple lessons how to make the first short programs would be very helpful, some example programs you have already in your zip.
If you like I can give some more hints to that point.
cu
klaus

I didn't know anyone ever used this, so I didn't continue work on it
What useful features are missing in your opinion?

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #16 on: March 03, 2017, 10:37:44 am »
It's working now, was a simple mistake I made: for testing micropython 134 and 146 I did rename the both files (micropython 134 for example). So the .py files couldn't get connected and also nAssembler didn't run. Now everthing works.

Hi ikj,
may be there are some things missing, that only few people shows interest to your assembler.
Some points:
-installing should be easy. In the text file its explained, but not every beginner is able to work with it. A step by step describing would be better and it should content every step, also installing ndless and microphyton and pyWrite or another editor. Should folders me made? Which and where? For example, it's not clear in the beginning, that files have to be put in an ndless folder at root.
Am using a nspire cx cas,
using os 4.4,
installed ndless 4.4,
started micropython (134/146) one time, as its told,
started nassembler but get error abour file format not supported.
May be that and the not so clear installation info hinders some interested people to try it.
Some simple lessons how to make the first short programs would be very helpful, some example programs you have already in your zip.
If you like I can give some more hints to that point.
cu
klaus

It's not the big thing but some simple aspects:
-as I said, a little more detailed instruction for all installing steps would be easier for the not so used ones. For example:

1. Get the actual OS version (now 4.4.0.xxx) from
https://education.ti.com/de/software/details/en/E7EE7A44207B41069B05C45A8149A7F9/ti-nspirecx_os
(don't know if links are allowed, otherwise a description how to get it from TI)
2. Install it. TI Link Software is needed.
https://education.ti.com/de/software/search/ti-nspire-cx-cas
and install it
3. backup everything on your nspire, all files will be deleted!
4. Start TI Link, connect your Nspire to your PC and install the new OS. Wait until all is done.

and so on. It's more in the style of 'XXX for dummies' or the 'Leittext Methode' (did work with it in education and it worked rather good. Especially beginners did like it.

Then some short lessons to help the people to learn how to handle the assembler, some basic infos and the example code for the first steps would hold it small and simple. Your examples can used for it very good. I think, what to do would be more some optical work and the principle of small steps as above. If you like I would try to do also some work for this (good chance to learn more about assembler...). It's clear to me that it can be a try to interest people and noone could say if this works. On worst case it would make loosing some time and work, but in every case it's a chance to get some more training by doing this (designing the lessons for example, improving my rude english :-)).
I didn't know anyone ever used this, so I didn't continue work on it
What useful features are missing in your opinion?
[/quote]

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #17 on: March 04, 2017, 05:50:21 am »
There has recently been some activity in the thread on tiplanet, and as a result I also made some updates, adding CLZ, ADR, and fixing a bug. I forgot to update the file in the first post, so now I removed it and added a link to the download on tiplanet, which should always be up to date.

It's working now, was a simple mistake I made: for testing micropython 134 and 146 I did rename the both files (micropython 134 for example). So the .py files couldn't get connected and also nAssembler didn't run. Now everthing works.

I agree that more documentation, more examples and some explanations of the examples would help. But my main reasons for starting this project were that I was interested in writing an assembler, had a lot of time with nothing to do, and I was always a bit annoyed that it was impossible to write native programs for the Nspire on-calc. Nowadays, I don't have much time, and I've accomplished my main goal of writing an on-calc assembler with most of the useful features.

I may try to write another example or two, but for more, other people will have to do it. So, you're welcome to do it

There probably already are some ARM assembler tutorials on the internet, for example for the GBA, but they can't explain the things specific to the Nspire, e.g. how to read the keyboard or display stuff (see https://hackspire.org and in particular https://hackspire.org/index.php/Memory-mapped_I/O_ports for that kind of thing), and they probably use some pseudo-instructions I didn't implement or some different syntax, which will require some experimenting and/or googling to adapt to nAssembler.

Also, grosged over on tiplanet wrote a small demo and a short explanation of ARM assembly, but it's in French. (example link: https://tiplanet.org/forum/archives_voir.php?id=839558, the file nsprtest.s is the code compatible with nAssembler)

« Last Edit: March 04, 2017, 05:56:06 am by lkj »

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #18 on: March 04, 2017, 12:54:51 pm »
Nice!

There has recently been some activity in the thread on tiplanet, and as a result I also made some updates, adding CLZ, ADR, and fixing a bug. I forgot to update the file in the first post, so now I removed it and added a link to the download on tiplanet, which should always be up to date.

It's working now, was a simple mistake I made: for testing micropython 134 and 146 I did rename the both files (micropython 134 for example). So the .py files couldn't get connected and also nAssembler didn't run. Now everthing works.
Quote

Quote
I agree that more documentation, more examples and some explanations of the examples would help. But my main reasons for starting this project were that I was interested in writing an assembler, had a lot of time with nothing to do, and I was always a bit annoyed that it was impossible to write native programs for the Nspire on-calc. Nowadays, I don't have much time, and I've accomplished my main goal of writing an on-calc assembler with most of the useful features.

Quote
I may try to write another example or two, but for more, other people will have to do it. So, you're welcome to do it

Jessus, Mary and Jo'... you say this to ME? IoI. There was a time when I was a little trying with Z80 Assembler on my ZX Specci. Hm, must have at 1983 or so... And by the time there came some nice books from UK about machine code routines and lastly the whole commented ROM of the Specci. So all system call could be used from the usual languages. Now i had what I needed but then my study ended, I got a job for long time and the lot of free time was gone. So how is it about the nspire os? Up to now I didnt find any large file or book w/o commented os routines, system calls, system variables. Some must be known, otherwise you wouldn't use a print function, input file and others in your code.

Quote
There probably already are some ARM assembler tutorials on the internet, for example for the GBA, but they can't explain the things specific to the Nspire, e.g. how to read the keyboard or display stuff (see https://hackspire.org and in particular https://hackspire.org/index.php/Memory-mapped_I/O_ports for that kind of thing), and they probably use some pseudo-instructions I didn't implement or some different syntax, which will require some experimenting and/or googling to adapt to nAssembler.

Yes, by searching I found several tutorials, it's very nice. Good, that the arm cpus are so much used. Indeed, what you telling about nspire os is the main point. Using/usability of an assembler depends from the documentation of the used machine. Also important, if this mc programs can easily be used from the usual languages as lua, python, c++, c. Should be simple calls that can easy done. And especially grafik routines, of course. I think, everyone, who is programming the nspire would be interested in this.

Quote
Also, grosged over on tiplanet wrote a small demo and a short explanation of ARM assembly, but it's in French. (example link: https://tiplanet.org/forum/archives_voir.php?id=839558, the file nsprtest.s is the code compatible with nAssembler)

Yes, and I will translate it by the time. Will surely need a little longer. In french I got at school usually the lowest note (from 1-6), the 6. But under those, who got ever the 6, I was one of the best. Means the 'best of the worst'. Sounds good, eh? :-) So it may need some time, also with using babelfish. Some time before, I saw a small list with os system calls. Damn, i don't remember where.

The resonance at TI Planet when you presented nAssembler was good, so I think there may be some who like to support the usage of it.

One first suggestion to the nAssembler: the handling is rather uncomfortable by typing the complete paths with the nspire keys. Could a file like the batch files of ms dos (in python?) make it simpler? Setting the paths to a constant one means that only the program name must be entered. If one has longer to do with a program he could also set the name in this batch file constant, so the the whole turnaround would be much shorter and simpler.

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #19 on: March 05, 2017, 05:28:34 pm »
I wrote about making the handling of nAssembler easier-so I tried by myself. But without being used in python I had no success. Was changing your code a little bit (yes, I know, it's a sacrileg), so that not the path but only the file name must be entered or in the other version path & filename get fixed to get a quick turnaround:

when I change your code at the end of the nassembler file

def calc_assemble():

inf = input('in:')
outf = input('out:')
return assembler(inf, outf)

to

def calc_assemble():

inf = /documents/ndless/example.asm.tns
outf = /documents/ndless/example.prg.tns
return assembler(inf, outf)

or

def calc_assemble():

inf = /documents/ndless/
inf = inf + input('in:')
outf = /documents/ndless/
outf = outf + input('out:')
return assembler(inf, outf)

all that doen't work, I get the 'File "/documents/ndless/nAssembler.py.tns", line 1600 Syntax Error: invalid Syntax. Tried also backslash for slashes but same reaction. Am wondering why I see 'nAssembler.py.tns' at the end of the string and not 'Example.asm.tns' as i wrote.

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #20 on: March 09, 2017, 05:55:39 pm »
I wrote about making the handling of nAssembler easier-so I tried by myself. But without being used in python I had no success. Was changing your code a little bit (yes, I know, it's a sacrileg), so that not the path but only the file name must be entered or in the other version path & filename get fixed to get a quick turnaround:

when I change your code at the end of the nassembler file

def calc_assemble():

inf = input('in:')
outf = input('out:')
return assembler(inf, outf)

to

def calc_assemble():

inf = /documents/ndless/example.asm.tns
outf = /documents/ndless/example.prg.tns
return assembler(inf, outf)

or

def calc_assemble():

inf = /documents/ndless/
inf = inf + input('in:')
outf = /documents/ndless/
outf = outf + input('out:')
return assembler(inf, outf)

all that doen't work, I get the 'File "/documents/ndless/nAssembler.py.tns", line 1600 Syntax Error: invalid Syntax. Tried also backslash for slashes but same reaction. Am wondering why I see 'nAssembler.py.tns' at the end of the string and not 'Example.asm.tns' as i wrote.
Found it now, was not so difficult:
inf="/documents/ndless/example.asm.tns"
and
outf="/documents/ndless/example.prg.tns"
so the turnaround gets a little faster. Now I am trying to get the clrscrn/countdown routine of grosged/TI Planet to assemble with nassembler. Last problem is the .word instruction. Hm, I saw this point anywhere in a forum...

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #21 on: March 10, 2017, 12:30:37 pm »
About the system calls: Yes, I guess it would be useful to have some way to access them with nAssembler. In programs compiled on the pc, ndless provides them.
Since neither reading keypad state nor displaying stuff on the screen uses them, you can actually already do many things without them, but there's obviously no file reading/writing.

.word is just called dcd here.

#### gr0sged

• LV0 Newcomer (Next: 5)
• Posts: 1
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #22 on: March 11, 2017, 12:35:16 pm »
Hello there!.. my very 1st post, here we go

Well!.. lkj, I had a question : do you intend to add a directive in nAssembler which would allow us to include binary files ? (I think about the useful directive .incbin available in Gnu Assembler)

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #23 on: March 13, 2017, 06:24:04 pm »
Sounds useful and simple to implement. I'll add it when I have time.

#### Chirlian

• LV2 Member (Next: 40)
• Posts: 22
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #24 on: March 14, 2017, 08:39:30 pm »
So it seems there is no os reassemble listing (with some comments)? Ok, in those days when we got such a book for the speccy it were 16 kb of rom. So making such a thing for the now 13 mb that the os contents would be an endless work. If there comes no infos from TI it may be to timesucking, esp. for a single person.
But when ndless contents some system calls, their programmers must know about them. However, they won't shout around with this knowledge that they got surely not without some trouble.
Thanks for the hint about .word/dcd!
About the system calls: Yes, I guess it would be useful to have some way to access them with nAssembler. In programs compiled on the pc, ndless provides them.
Since neither reading keypad state nor displaying stuff on the screen uses them, you can actually already do many things without them, but there's obviously no file reading/writing.

.word is just called dcd here.

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #25 on: April 03, 2017, 02:18:01 pm »
The INCBIN directive is now implemented. The syntax is
INCBIN path
, i.e. no double quotes or anything around the path. It includes the file content at the location of the INCBIN. path can be an absolute path or a relative path (relative to the  directory containing the source file).

So it seems there is no os reassemble listing (with some comments)? Ok, in those days when we got such a book for the speccy it were 16 kb of rom. So making such a thing for the now 13 mb that the os contents would be an endless work. If there comes no infos from TI it may be to timesucking, esp. for a single person.
But when ndless contents some system calls, their programmers must know about them. However, they won't shout around with this knowledge that they got surely not without some trouble.
No, since TI doesn't support native programming on the Nspire. The people working on ndless have found many system calls over the years, though. Since ndless is open source, the addresses can be found there (https://github.com/ndless-nspire/Ndless/tree/master/ndless/src/tools/MakeSyscalls/idc). But copying them from there and hardcoding them in your assembly source is very annoying, because the addresses are different for every OS version and for the different models. So it would be much nicer if nAssembler had some support for syscalls.
Edit: It's actually easier than that. Since ndless executes the assembled program, we can actually use its way to handle syscalls: Ndless installs a SWI handler, so we can just use the SWI (software interrupt) instruction to call syscalls. The syntax is "SWI swinum", where swinum is the number of the syscall you want, from the list at https://github.com/ndless-nspire/Ndless/blob/master/ndless-sdk/include/syscall-list.h. So for example "SWI 0" to call fopen.
« Last Edit: April 03, 2017, 02:33:12 pm by lkj »

#### neuronix

• LV4 Regular (Next: 200)
• Posts: 108
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #26 on: September 10, 2017, 11:26:21 am »
And how can I send arguments to swi?

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #27 on: September 11, 2017, 03:04:37 am »
If I remember correctly you pass arguments as with normal function calls, that is in r0, r1 etc

#### neuronix

• LV4 Regular (Next: 200)
• Posts: 108
• Rating: +0/-0
##### Re: nAssembler - Nspire on-calc assembler
« Reply #28 on: September 15, 2017, 03:37:42 pm »
so, for #define e_puts 22 // int nuc_puts(const char *p1)
it's my code:
Code: [Select]
main    stmfd sp!, {r0-r12, lr}    adr r0, text    swi #22    bl wait    ldmfd sp!, {r0-r12, pc}wait    stmfd sp!, {r0-r12, lr}    mvn r0, #0    mov r0, r0, lsr #4waitloop    sub r0, r0, #1    cmp r0, #0    bgt waitloop    ldmfd sp!, {r0-r12, pc}text    dcb "Hello World!"Is it good?
« Last Edit: September 15, 2017, 07:52:30 pm by neuronix »

#### lkj

• LV6 Super Member (Next: 500)
• Posts: 485
• Rating: +58/-1
##### Re: nAssembler - Nspire on-calc assembler
« Reply #29 on: September 17, 2017, 03:45:59 pm »
I think it's correct.