But its very easy to have the best of both worlds, example, ease of basic and just as portable and the speed and size of assembly.
First the inc (this is the bit that changes for all platform or os)
DBasic_L.inc
Code: Select all
;============================================================
; DexBasic is based on a idea by rCX, for a fasm macro basic.
; The esae of basic, with the power of ASM.
;
; Code input by:
; Dex
; rCX
; Steve
; TonyMac
;
; This include is for x86 32BIT Linux.
;
;============================================================
;======================================================= ;
; File header. ;
;======================================================= ;
format ELF executable ;
entry start ;
;
;======================================================= ;
; CLS. ;
;======================================================= ;
macro CLS ;
{ ;
local .Done ;
local .a ;
local .b ;
;
mov eax,4 ; Print function
mov ebx,1 ;
mov ecx,.a ;
mov edx,.b ;
int 80h ;
jmp .Done ;
;
.a db 1bh, "[2J",1bh, "[01;01H" ; clear screen.
.b = $-.a ;
.Done: ;
} ;
;
;======================================================= ;
; PRINT. ;
;======================================================= ;
macro PRINT String{ ;
local .Done ;
local .a ;
local .b ;
;
mov eax,4 ; Print function
mov ebx,1 ;
mov ecx,.a ;
mov edx,.b ;
int 80h ;
jmp .Done ;
;
.a db String,0xa ;
.b = $-.a ;
.Done: ;
} ;
;
;======================================================= ;
; LOCATE. ;
;======================================================= ;
macro LOCATE col,row ;
{ ;
local .Done ;
local .CursorX ;
local .CursorY ;
local .ColumnRow ;
local .ColumnRowSize ;
pushad ;
mov dh, 10 ;
;
mov ax, row ; AX = character column
and ax, 0FFh ;
div dh ; divide by 10
add ax, "00" ;
mov [.CursorX], ax ;
;
mov ax, col ; AX = character row
and ax, 0FFh ;
div dh ; divide by 10
add ax, "00" ;
mov [.CursorY], ax ;
;
mov eax,4 ; Print function
mov ebx,1 ;
mov ecx,.ColumnRow ;
mov edx,.ColumnRowSize ;
int 80h ;
jmp .Done ;
;
;
.ColumnRow db 1bh, "[" ; cursor positioning sequence
.CursorX dw 0 ;
db ";" ;
.CursorY dw 0 ;
db "H" ;
.ColumnRowSize = $-.ColumnRow ;
.Done: ;
popad ;
} ;
;
;======================================================= ;
; END. ;
;======================================================= ;
macro COLOR NewColor ;
{ ;
local .Done ;
local .Done1 ;
local .black ;
local .red ;
local .green ;
local .yellow ;
local .blue ;
local .magenta ;
local .cyan ;
local .white ;
local .Size1 ;
local .Size2 ;
;
mov al,NewColor ;
cmp al,15 ;
ja .Done ;
cmp al,15 ;
jne @f ;
mov ecx,.white ;
jmp .Done1 ;
@@: ;
cmp al,0 ;
jne @f ;
mov ecx,.black ;
jmp .Done1 ;
@@: ;
cmp al,11 ;
jne @f ;
mov ecx,.cyan ;
jmp .Done1 ;
@@: ;
cmp al,12 ;
jne @f ;
mov ecx,.red ;
jmp .Done1 ;
@@: ;
cmp al,14 ;
jne @f ;
mov ecx,.yellow ;
jmp .Done1 ;
@@: ;
cmp al,10 ;
jne @f ;
mov ecx,.green ;
jmp .Done1 ;
@@: ;
cmp al,13 ;
jne @f ;
mov ecx,.magenta ;
jmp .Done1 ;
@@: ;
cmp al,9 ;
jne @f ;
mov ecx,.blue ;
jmp .Done1 ;
@@: ;
jmp .Done ;
.Done1: ;
mov eax,4 ; Print function
mov ebx,1 ;
mov edx,.Size2 ;
int 80h ;
jmp .Done ;
;
;
.black db 1bh, "[0;30;49m" ;
.red db 1bh, "[0;31;49m" ;
.green db 1bh, "[0;32;49m" ;
.yellow db 1bh, "[0;33;49m" ;
.blue db 1bh, "[0;34;49m" ;
.magenta db 1bh, "[0;35;49m" ;
.cyan db 1bh, "[0;36;49m" ;
.white db 1bh, "[0;37;49m" ;
.Size1 db 1bh, "[0;39;49m" ;
.Size2 = $-.Size1 ;
.Done: ;
} ;
;
;======================================================= ;
; GOTO. ;
;======================================================= ;
Macro GOTO _op1 ;
{ ;
jmp _op1 ;
} ;
;
;======================================================= ;
; GOSUB. ;
;======================================================= ;
Macro GOSUB _subname ;
{ ;
call _subname ;
} ;
;
;======================================================= ;
; RETURN. ;
;======================================================= ;
Macro RETURN ;
{ ;
ret ;
} ;
;
;======================================================= ;
; SLEEP. ;
;======================================================= ;
macro SLEEP ;
{ ;
pushad ;
mov eax,3 ;
xor ebx,ebx ;
mov ecx,1 ;
mov edx,buffer ;
int 80h ;
popad ;
} ;
;
;======================================================= ;
; END. ;
;======================================================= ;
macro END ;
{ ;
local .Done ;
local .restore ;
local .Size2 ;
pushad ;
mov ecx,.restore ;
mov eax,4 ; Print function
mov ebx,1 ;
mov edx,.Size2 ;
int 80h ;
;
mov eax,1 ; Exit function
xor ebx,ebx ;
int 80h ;
jmp .Done ;
;
.restore db 1bh, "[0;39;49m" ;
.Size2 = $-.restore ;
.Done: ;
popad ;
} ;
;
;======================================================= ;
; START of Program. ;
;======================================================= ;
segment readable writeable executable ;
buffer rb 1 ;
start: ;
This stays the same other than the .inc
Hello_world.asm
Code: Select all
include 'DBasic_L.inc'
CLS
COLOR 11
LOCATE 2,1
PRINT "This app is written in Macro Basic, for Linux "
COLOR 12
LOCATE 2,2
PRINT "With the ease of Basic and the power of ASM "
COLOR 15
LOCATE 2,3
PRINT "It user's the basic commands:"
PRINT " "
PRINT " CLS"
PRINT " SCREEN"
PRINT " COLOR"
PRINT " LOCATE"
PRINT " PRINT"
PRINT " GOSUB"
PRINT " RETURN"
PRINT " SLEEP"
PRINT " END"
PRINT " "
GOSUB TestSub
SLEEP
END
TestSub:
PRINT " Press any key to quit."
RETURN
You could very easy port it to riscos.
It also can be run bare metal on the pi
