Jump to content


Photo

Canonic Assembler


  • Please log in to reply
1 reply to this topic

#1 openxdkman

openxdkman

    X-S Genius

  • Moderator
  • PipPipPipPip
  • 823 posts
  • Xbox Version:unk
  • 360 version:unknown

Posted 10 April 2007 - 01:35 PM

Minidash (and probably other independant software) will be able to relocate, pre-process and execute programs written in canonic assembler.

What's that?

In mathematics, 'canonic' means 'simplest' (can't reduce it more).
Main interest of canonic assembler is to allow to write interpreted code.
The Canonic Engines (interpreters) are easy to implement quickly.
You lose speed (10 up to 100 times slower than compiled native code), but you save research & development time, especially when you are trying to design a driver on a recently hacked environment, because you just need... notepad. Micro-codes uploaded in co-processors are NOT slowed down...
Relocation and symbol pre-processing is performed directly from text file.

Rules:
1 instruction per line
1 character per instruction name
1 operand per instruction

Here is the syntax details (kept voluntarily short) :
http://minilgos.pers...sh/casyntax.txt

It may still evolve (but I doubt). I'm currently studying xbox360 homebrew to see if it needs adjustments (probably some 32 bits aliases for the 128 bits port addresses).
(and when the current 'curse' gets lifted from the PS3 scene, I will examine PS3 homebrew too...)

A very clean "hello world" program would look like this :

CODE

02,1+1
//reserve space for 2 labels, 1 local and 1 global

//global register (stores line number in debug mode)
$$g_line

//unified api functions IDs
$$print=6

//code entry point
@@main=0

@msg
    S'Hello world'
    S'0d
    S'0a
    S'0

//activate debug mode 1 from here
~~1

@main
    $
    $ret
    "msg
    #print
    L!0
    Sret
    Rret

//turns off debug mode
~~0



A smaller but dirtier version would look like this :

CODE

02,0+0
@main
    "msg
    #6
    R!0
@msg
    S'Hello world'
    S'0


More samples (ogg vorbis decoder, already tested successfully on pc0) and more explanations will come when Minidash v0.1 will be released...

Edited by openxdkman, 28 March 2009 - 10:49 PM.


#2 openxdkman

openxdkman

    X-S Genius

  • Moderator
  • PipPipPipPip
  • 823 posts
  • Xbox Version:unk
  • 360 version:unknown

Posted 13 April 2007 - 05:06 PM

Here is a program that calls printf and draws a sinus function (fpu used).
There are plenty of useless global variables and constants just to show you syntax.

CODE

010,10+10
//0N,L+G :10 labels, 10 local registers + 10 global registers
//First char of first line must be '0' in canonic code

//Global macros (max 32500 chars in global macros string at any time)

// Global macros used as registers names:
// Each new pre-processing starts with global macro string "...=<L-1>"
// Next vars will start automatically at value L (see "0N,L+G")
// First global register can receive source line at run time for debug
// Second and third global register can be used as references as well
$$g_line,g_compare1,g_compare2
$$g_table[16]
$$g_last_global

// Global macros used as constants:
$$PI=!3.14159f
$$TABLE_SIZE=32

// Global macros used as unified api function IDs
$$plot=0,hline,vline,dline,rline
$$printf,print
$$malloc,free,calloc,realloc,ext_ram_left
$$comp,copy,clear,scanb,scanw,scanl
$$read_input,write_output,seek_input,seek_output,tell_input,tell_output
$$dbgprintline,dbgcheckram,dbgcompequ,dbgcomplt
$$getch
$$mdct,iwin,awin,convsamp

$$finit=61440
$$f2xm1,fabs,fchs,fpatan,fprem,fptan,frndint
$$fscale,fxtract,fsqrt,fxch,fyl2x,fyl2xp1
$$fld1,fldl2t,fldl2e,fldpi,fldlg2,fldln2,fldz
$$fsin,fcos,fsincos

// Global macros used as structures members offsets:
$$my_struct_first_member=!0
$$my_struct_dwords_table[TABLE_SIZE]
$$my_struct_size
$$my_2nd_struct_first_member=%0
$$my_2nd_struct_shorts_table[TABLE_SIZE]
$$my_2nd_struct_size

//Labels (max 32500 chars in labels macros string at any time)
@@main=0
//Compels incoming label 'main' to have value zero (code entry point)
//(allows you to put 'main' function code at bottom of file)

//Constant strings
@msg
S'Hello world %ld %04lx %s'
S'0a
S'0d
S'0
@name
S'<name>'
S'0

//let's ask for debug information (0=none, 1=report g_line)
~~1

////////
//main//
////////

@main
    $
    $ret,i,p1,p2,p3,x,y,c,fi

    Pp1
    L!7d7
    Sp1
    L!babe
    Sp2
    "name
    Sp3
    "msg
    #printf

    #finit

    L!0
    Si
@loop
        Li
        +!200
        Sx
    
        .
        Li
        sfi
        
        #fldpi
        *fi
        /!64.0
        #fsin
        *!-10.0
        +!384.0
        Sy
                
        L!0
        Sc

        Px
        #plot
    
        Li
        +!1
        Si
        <!100
        Tloop

    L!0
    Sret
    Rret

//turns off debugging mode (faster execution for code after this line)
~~0

//keyboard scancodes for getch
//0x01 escape
//0x1c enter
//0x39 space
//0xc8 up
//0xd0 down
//0xcb left
//0xcd right

Edited by openxdkman, 10 June 2007 - 10:04 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users