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.
DexBasic Source code
29 posts
Page 1 of 2 1, 2
Hi,
Does this update include the low-level functions for http://elm-chan.org/fsw/ff/en/appnote.html ?
Thanks.
Does this update include the low-level functions for http://elm-chan.org/fsw/ff/en/appnote.html ?
Thanks.
- Posts: 90
- Joined: Sat Sep 08, 2012 1:59 pm
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.
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.
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
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:
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.
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
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
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: 77
- Joined: Tue Jan 03, 2012 7:10 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

Running on linux

Running on the PI

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.
@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

Running on linux

Running on the PI
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.
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
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
@Devidas
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
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
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: 77
- Joined: Tue Jan 03, 2012 7:10 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
I wait for that.
Devidas
- Posts: 2
- Joined: Sun Dec 23, 2012 11:45 am
@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)
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.
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
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
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: 77
- Joined: Tue Jan 03, 2012 7:10 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:
It would then be converted to:
The output could then even be included into a new macro for DexBasic.
Now that would make for a fantastic assembler teaching tool.
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
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
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.
Thanks Dex, some nice new commands which will be very useful.
- Posts: 172
- Joined: Tue Dec 25, 2012 12:52 pm
could i make realtime chart with dexBasic?
thank you
rizal
thank you
rizal
- Posts: 5
- Joined: Tue Nov 27, 2012 1:41 am
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.
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
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
Batteries not included, Some assembly required.
Happy Birthday Dex.
Party it up
Party it up
- Posts: 172
- Joined: Tue Dec 25, 2012 12:52 pm
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
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
im so sorry for my rudeness, really sorry
thank you for guide dex,
im really really sorry dex
thank you for guide dex,
im really really sorry dex
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
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.
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: 1206
- Joined: Sun Sep 11, 2011 2:32 pm
tufty is right, we are not getting paid, we help because we are kind and when we have time.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.
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.
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
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: 77
- Joined: Tue Jan 03, 2012 7:10 pm