DexBasic Source code


29 posts   Page 1 of 2   1, 2
by DexOS » Tue Dec 25, 2012 3:10 am
Here is the DexBasic ASM source code as promised.
Its fully open source as long as you include the license.
http://www.dex-os.com/DexOS_R_PI/DexBasicSource.zip

Theres also some more function added, a bigger release will be released at end of January, with many more functions.
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by Arjan » Tue Dec 25, 2012 10:22 am
Hi,

Does this update include the low-level functions for http://elm-chan.org/fsw/ff/en/appnote.html ?

Thanks.
Posts: 128
Joined: Sat Sep 08, 2012 1:59 pm
by DexOS » Tue Dec 25, 2012 11:10 am
Arjan wrote:Hi,

Does this update include the low-level functions for http://elm-chan.org/fsw/ff/en/appnote.html ?

Thanks.

It includes:
disk_initialize
disk_status
disk_read
see "SdMmc.inc"
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by Rene_is_I » Tue Dec 25, 2012 12:56 pm
Thanks DexOS this is more what should have been released with the Pi from the start,
a simple BASIC which also lets one add commands as one gets better at it and more confident.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by Rene_is_I » Tue Dec 25, 2012 4:28 pm
Just been thinking that it would be great to have a BEEP command similar to the one on the Spectrum.
Something along the lines of:
BEEP xxxx (where xxxx is the frequency or 0 to stop).
Would be nice to be able to play those simple chiptunes from yesteryear.
For example:

Code: Select all
BEEP 400
delayMicroseconds 300000
BEEP 824
delayMicroseconds 500000
BEEP 945
delayMicroseconds 1000000
BEEP 440
delayMicroseconds 800000
BEEP 0


I see from the circuit diagram that the PWM is connected to the 3.5mm stereo jack from GPIO40 and GPIO45

(some info here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=72&t=25606

I'm guessing it would be a case of selecting the right clock frequency (plus setting other regs) to
get the required BEEP frequency.
What I can't work out is if each peripheral can have different clock frequencies at the same time,
for example if one is using the UART and BEEP which would most likely require different clock frequencies.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by tritonium » Tue Dec 25, 2012 5:32 pm
Hi Dex (Craig)
Hooray
I've been quietly waiting for this since July when you first announced Dexos / DexBasic.
I have been wanting to write an application that booted quickly with full use of screen, usb and file-handling.
Until now I've used msdos and qbasic but systems that run even that are getting too sophisticated and to do this on the Pi is going to be FUN.
I have to admit the assembler instructions for the pi left me gasping to start with, not even being able to load a register immediately but having to use a multi-instruction macro instead. (amongst other things).
Still, by looking at your code I will learn lots.
I am not a christmas lover, but a present like this is welcome any day.
Many many THANKS!

Dave H
Posts: 78
Joined: Tue Jan 03, 2012 7:10 pm
by DexOS » Wed Dec 26, 2012 12:32 pm
Thanks for the for both your comments.

@tritonium, there's a dos ver of DexBasic so you can run the same code on the PI, dos, windows, linux, x86 ver of DexOS, by just changing the DexBasic.inc and reassembling it.

Running on x86 ver of DexOS
Image

Running on linux
Image

Running on the PI
Image

Only the inc file needs changing.
Also try x86 ver of DexOS in stead of Dos
See here:
http://www.youtube.com/watch?v=mYJx2zZK7c8
http://www.youtube.com/watch?v=p-XXCSxlUng
Its includes a full tcp/ip stack
http://www.youtube.com/watch?v=LdXhuZ0sAD4

Also note you can run x86 ver of DexOS on top of dos and return back to dos.
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by devidasbhonde » Thu Dec 27, 2012 6:48 am
Dear Craig,

Thank you very much for this Pi basic !! (I am almost zero in C...) I can do VB6 though.
Have been doing 8 bit micros and ofcoarse plain electronics. Use BASCOM compiler.
Now I can write for PI.
I am eagerly waiting for additional instructions of basic.
I have a small marking machine having stepper motors and slides etc. Using Atmel 89C52.
Is is possible to use Pi and make it faster and better ? Draw circles etc ?

Best Regards and Merry Christmas.
Devidas from India
Posts: 2
Joined: Sun Dec 23, 2012 11:45 am
by tritonium » Thu Dec 27, 2012 1:55 pm
@Devidas
I have a small marking machine having stepper motors and slides etc. Using Atmel 89C52.
Is is possible to use Pi and make it faster and better ? Draw circles etc ?

Ah, Basic lovely Basic - dont you just love it.
Yes - think of the Pi (in bare metal) as a super microcontroller with terriffic graphic capability and with Basic fully and easily controllable (as long as people like Dexos provide us with the tools!). Not bothered having to share resources with other multi-tasking operations (Linux etc) but having the processor ALL to yourself.
Dexos has already shown how to control steppers in his Basic

Code: Select all
include 'DexBasic\DexBasic.inc'                   
count     = 2000                                   ; 1000
motorPin1 = GPIO17                                 ; Blue   - 28BYJ48 pin 1
motorPin2 = GPIO18                                 ; Pink   - 28BYJ48 pin 2
motorPin3 = GPIO21                                 ; Yellow - 28BYJ48 pin 3
motorPin4 = GPIO22                                 ; Orange - 28BYJ48 pin 4
                                                   ;
pinMode  GPIO17, OUTPUT                            ;
pinMode  GPIO18, OUTPUT                            ;
pinMode  GPIO21, OUTPUT                            ;
pinMode  GPIO22, OUTPUT                            ;
                                                   ;
LetsLoop:                                          ; counterclockwise
  imm32        r2,500                              ;
CounterClockWise:                                  ;
  digitalWrite motorPin4, HIGH                     ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, HIGH                     ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin1, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin1, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin1, HIGH                     ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, HIGH                     ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin4, HIGH                     ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, HIGH                     ;
  delayMicroseconds count                          ;
  subs         r2,r2, 1                            ;
  bne          CounterClockWise                    ; clockwise
                                                   ;
  digitalWrite motorPin4, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin1, LOW                      ;
                                                   ;
  imm32        r2,500                              ;
ClockWise:                                         ;
  digitalWrite motorPin1, HIGH                     ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, HIGH                     ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, HIGH                     ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin4, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin4, LOW                      ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, HIGH                     ;
  digitalWrite motorPin4, HIGH                     ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, HIGH                     ;
  delayMicroseconds count                          ;
                                                   ;
  digitalWrite motorPin1, HIGH                     ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, HIGH                     ;
  delayMicroseconds count                          ;
  subs         r2,r2, 1                            ;
  bne          ClockWise                           ; clockwise
                                                   ;
  digitalWrite motorPin1, LOW                      ;
  digitalWrite motorPin2, LOW                      ;
  digitalWrite motorPin3, LOW                      ;
  digitalWrite motorPin4, LOW                      ;
goto  LetsLoop                                   
                                                   ;
align 4                                           
ProgramSize:                                       ;
ScreenBuffer:                                      ;
       


Find it here hthttp://www.raspberrypi.org/phpBB3/viewtopic.php?f=72&t=13059&start=25

It will be fun to see how small we can make this without having to lay out all the intructions in a linear fashion, ie by using variables and loops.


Dave H
Posts: 78
Joined: Tue Jan 03, 2012 7:10 pm
by devidasbhonde » Thu Dec 27, 2012 3:28 pm
Yes. I wish to have different variables... bytes, integers.. And loops, If - then Then that basic code will be real fun.
I wait for that.

Devidas
Posts: 2
Joined: Sun Dec 23, 2012 11:45 am
by Rene_is_I » Thu Dec 27, 2012 3:45 pm
@devidasbhonde

Dex said that he would add IF/THEN/ELSE soon.
As far as conditional statements/branching is concerned, there is a simple work around for now
using assembler (not that difficult) until it is added into Basic.

For example we read a pin from the GPIO (which returns either a 0 or 1 in register r0) and branch
depending if it's high or low:

(This code was originally posted by Dex)

Code: Select all
include 'DexBasic\DexBasic.inc'               
val equ r0                                       
                                                 
pinMode  GPIO18, INPUT                         
pinMode  GPIO16, OUTPUT                           

; ==============================                                                 
LetsLoop:   
; ==============================
                                     
delayMicroseconds  1000                         
digitalRead   GPIO18                               
cmp   val,1              ; digitalRead returns value in r0                                 
blt   TurnLedOn                                   
digitalWrite  GPIO16, LOW                         
goto  LetsLoop   

; ==============================                                 
TurnLedOn:   
; ==============================
                                 
digitalWrite  GPIO16, HIGH                       
goto  LetsLoop               


The cmp val,1 is the comparison and the blt TurnLedOn will cause the pgm to branch
to TurnLedOn if it is a 1.

You could also make your own IF command by writting your own macro and placing it in the .inc file.
That is the beauty about using macros, it makes it very easy to add new stuff.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by tritonium » Thu Dec 27, 2012 4:58 pm
Yep
Isn't it GREAT!
Use a high level language and supplement with assembler when necessary.
What a great way to learn assembler!!
Dave H
Posts: 78
Joined: Tue Jan 03, 2012 7:10 pm
by Rene_is_I » Thu Dec 27, 2012 5:59 pm
@tritonium

Absolutely and simply by using a different .inc file, the same Basic code will work with the RPI, X86 Windows and Linux.

What would be great is to find a utility that one writes in Basic and it converts it to an ASM text file.
A very simple example:

Code: Select all
A = 200
Goto SomeLabel


It would then be converted to:

Code: Select all
mov r0, 200
b SomeLabel


The output could then even be included into a new macro for DexBasic.
Now that would make for a fantastic assembler teaching tool.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by DexOS » Thu Dec 27, 2012 6:15 pm
Glad people find DexBasic useful, some of what you want added have been add to by a DexOS forum member called "timfv", i have not had chance to fully test them yet, but your welcome to try, they are available here:
http://www.dexbasic.tf-v.com/DexBasic.zip

I will be adding them to the next ver of DexBasic.
Dex
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by Rene_is_I » Thu Dec 27, 2012 6:32 pm
Thanks Dex, some nice new commands which will be very useful.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by apriansyahrizal » Fri Apr 12, 2013 8:12 am
could i make realtime chart with dexBasic?
thank you

rizal
Posts: 5
Joined: Tue Nov 27, 2012 1:41 am
by DexOS » Fri Apr 12, 2013 4:57 pm
apriansyahrizal wrote:could i make realtime chart with dexBasic?
thank you

rizal

Yes, you could, but it would be similar to how you would need to code it for a OS like Dos, other than you would have higher res graphics.
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by apriansyahrizal » Mon Apr 15, 2013 5:28 am
DexOS wrote:
apriansyahrizal wrote:could i make realtime chart with dexBasic?
thank you

rizal

Yes, you could, but it would be similar to how you would need to code it for a OS like Dos, other than you would have higher res graphics.


thanks for fast response Dex,
btw do you have some example code for drawing in DexBasic languange
like a simple drawline from(1,0) to (7,3)

rizal
Posts: 5
Joined: Tue Nov 27, 2012 1:41 am
by DexOS » Mon Apr 15, 2013 4:38 pm
apriansyahrizal wrote:
DexOS wrote:
apriansyahrizal wrote:could i make realtime chart with dexBasic?
thank you

rizal

Yes, you could, but it would be similar to how you would need to code it for a OS like Dos, other than you would have higher res graphics.


thanks for fast response Dex,
btw do you have some example code for drawing in DexBasic languange
like a simple drawline from(1,0) to (7,3)

rizal

Hi apriansyahrizal,
I have written the functions for line drawing etc, but i have not add it to the main DexBasic.inc, i will add it and release it tomorrow, as it's my birthday and i am going to party tonight 8-)
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by Rene_is_I » Mon Apr 15, 2013 4:44 pm
Happy Birthday Dex.
Party it up :D
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by apriansyahrizal » Thu Apr 18, 2013 4:35 am
apriansyahrizal wrote:
DexOS wrote:
apriansyahrizal wrote:thanks for fast response Dex,
btw do you have some example code for drawing in DexBasic languange
like a simple drawline from(1,0) to (7,3)

rizal

Hi apriansyahrizal,
I have written the functions for line drawing etc, but i have not add it to the main DexBasic.inc, i will add it and release it tomorrow, as it's my birthday and i am going to party tonight 8-)


oh thankyou very much dex, where i can get the latest DexBasic.inc
and happy birthdayy for you ;)
Posts: 5
Joined: Tue Nov 27, 2012 1:41 am
by apriansyahrizal » Fri Apr 26, 2013 9:08 am
im so sorry for my rudeness, really sorry :(
thank you for guide dex,

im really really sorry dex :oops:
Last edited by apriansyahrizal on Mon Apr 29, 2013 4:55 am, edited 1 time in total.
Posts: 5
Joined: Tue Nov 27, 2012 1:41 am
by tufty » Fri Apr 26, 2013 9:18 am
And now wonder why people get fed up with giving away the source to their work.

Dex owes you nothing, zip, nilch, nada. "I'm still waiting" is rude enough, but adding a "rolling eyes" emoticon to the end makes me, personally, want to go postal. Enjoy your wait. And maybe learn some manners whilst you're waiting.
Posts: 1330
Joined: Sun Sep 11, 2011 2:32 pm
by DexOS » Fri Apr 26, 2013 11:02 pm
tufty wrote:And now wonder why people get fed up with giving away the source to their work.

Dex owes you nothing, zip, nilch, nada. "I'm still waiting" is rude enough, but adding a "rolling eyes" emoticon to the end makes me, personally, want to go postal. Enjoy your wait. And maybe learn some manners whilst you're waiting.
tufty is right, we are not getting paid, we help because we are kind and when we have time.
And as tufty pointed out you will be waiting a long time as i am take a rest from coding.
I would just like to say thanks to the people that have give good info and feed back on this sub forum and good luck with all your projects.
Regards Dex.
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by tritonium » Sat Apr 27, 2013 5:07 pm
Dex
I do hope you're not leaving because of illnes.
I for one have enjoyed your input and help and hope you will be back soon.
Are you REALLY hanging up your coding irons, or taking on challenges elsewhere? Once bitten by the coding bug its hard to give up - I know.
If you don't already know of it, there is a new processor on the building board at Parallax the message board is -
http://forums.parallax.com/forumdisplay.php/97-Propeller-2-Multicore

The propellar 1 has been around for a few years but this new version is going to rock a few boats - it has eight cores, and just one core can generate hi res video, so I am hoping it will be able to do what I want. (I am finding the Pi a bit of a letdown - it does all the designers hoped, but I am not a big operating system (Linux) guy).

Although the silicon for the prop2 is not yet available, an fpga image of the prop2 is available and people are eagerly testing the design out as details are being documented.
If nothing else its nice to be looking over the shoulders of others and being infected by their enthusiasm.

Regards

Dave
Posts: 78
Joined: Tue Jan 03, 2012 7:10 pm