Skip to content

Instantly share code, notes, and snippets.

@arydevy
Created July 20, 2021 09:16
Show Gist options
  • Select an option

  • Save arydevy/88f6f67887a0a127aa3ab758b004bdcd to your computer and use it in GitHub Desktop.

Select an option

Save arydevy/88f6f67887a0a127aa3ab758b004bdcd to your computer and use it in GitHub Desktop.

Revisions

  1. arydevy created this gist Jul 20, 2021.
    110 changes: 110 additions & 0 deletions SPEC.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,110 @@
    ---------------------

    -- Lumos-5 cpu instruction set. --

    Lumos-5 is a virtual cpu made for cross platform
    programming.With Lumos-5 you can write asambly
    code for this cpu and the emulator or compiler
    will make the code work on all os/cpu supported.

    The idea is to have a 32 bit cpu that has very
    similar performance to somthing written on the
    os/cpu for all supported platforms.

    Platforms:
    Linux
    Windows
    MacOs

    Android
    Ios


    Spec Version - 0.1 7/20/2021
    ---------------------


    General:
    - Big Endian
    - 32 bit
    - 32 bit address bus


    Registers [q,k] [bq,bk] are part of registers [aq,ak].

    -----[REGISTERS]-----

    q - GP 8bit register
    w - GP 8bit register
    x - GP 8bit register
    y - GP 8bit register
    z - GP 8bit register
    k - GP 8bit register

    bq - GP 16bit register
    bw - GP 16bit register
    bx - GP 16bit register
    by - GP 16bit register
    bz - GP 16bit register
    bk - GP 16bit register

    aq - GP 32bit register
    aw - GP 32bit register
    ax - GP 32bit register
    ay - GP 32bit register
    az - GP 32bit register
    ak - GP 32bit register

    er - special 8bit register keeping a error code used for debugging.

    Flags:
    G - Greater
    E - Equal
    C - Carry
    B - Borrow
    S - is in subroutine

    Instructions int this spec version are in the form 0x0000
    R - Register
    D -Data coud be a number address or anything
    A - Address on bus
    F - Flag
    N - Number
    none - no argument
    ------[INSTRUCTIONS]-----
    0x0000 DN none - Dose Nothing
    0x0001 MV R,D - Moves data to the register
    0x0002 ST R,A - Copies the register to the memory addres
    0x0003 SET F - Sets flag to 1
    0x0004 CLF F - Sets flag to 0
    0x0005 ADD R,N/R - Adds a number to another number in a register and overwrites the register with the result
    0x0006 SUB R,N/R - Subtracts n from a register
    0x0007 MUL R,N/R - Multiplies R by N
    0x0008 DIV R,N/R - Divide R by N
    0x0009 PUSH R/A - Push R to the stack
    0x000A POP R - Pops a item from the stack and stores it in R
    0x000B AND R,A/R - Perform a and operation between the arguments
    0x000C OR R,A/R - Perform a or operation between the arguments
    0x000D NOR R,A/R - Perform a Not opperation between the args
    0x000E CMP R,A/R - Compare the args and set the requiered flags
    0x000F JMP A - Jump to a address
    0x0010 JEQ A - Jumps if the Equal flag is set
    0x0011 JNE A - Jumps if the Equal flag is not set
    0x0012 JG A - Jumps if the Greather flag is set
    0x0013 JS A - Jumps if the Graather flag is not set
    0x0014 END R - Stops execution returning R
    0x0015 RST none - Resets the cpu
    0x0016 CALL A - Loads the current address of the istructions on the stack sets the S flag and jumps to A
    0x0016 JMB nome - Jumps back to the address on the stack if the S flag is set


    -----[ERROR CODES]-----
    TODO


    -----[MEMORY LAYOUT]-----
    0x00000000 -> 0x00000001 PC/Program Counter
    0x00000002 -> 0x00000003 SP/Stack Pointer
    0x00000004 -> 0x0000000F Stack