Thread: What should I Implement next?

  1. #1
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709

    What should I Implement next?

    I wasn't sure where to put this thread so I've just posted it here since it's the first forum on the list

    Here's the instructions I've implemented so far:

    Code:
    Opcode  Mnemonic    Operands    Registers Affected  Flags Affected  Comment
    ------  --------    --------    ------------------  --------------  -------
    
    0000    nop         -, -        -                   -               No Operation
    FFFF    end         -, -        PC, SP              -               End of program [reset PC]
    0001    push        r/k, -      SP                  -               Push value to stack
    0002    pop         r, -        SP                  -               Pop value off top of stack into r
    0003    mov         r, r        -                   Z               Move (copy) value in r into r
    0004    inc         r, -        -                   Z               Increment value in r
    0005    dec         r, -        -                   Z               Decrement value in r
    0006    jmp         k, -        PC                  -               Unconditional jump to instruction at memory
                                                                        location k
    0007    cmp         r/k, r/k    -                   Z, E, LT, GT    Compare r/k with r/k
    0008    je          k, -        PC                  -               Jump to instruction @ k if E is set
    0009    jne         k, -        PC                  -               Jump to instruction @ k if E not set
    000A    jz          k, -        PC                  -               Jump to instruction @ k if Z is set
    000B    jnz         k, -        PC                  -               Jump to instruction @ k if Z not set
    000C    jgt         k, -        PC                  -               Jump to instruction @ k if GT is set
    000D    jlt         k, -        PC                  -               Jump to instruction @ k if LT is set
    000E    ld          r, k        -                   Z               Load r with value k
    Some modifications and fixes still need to be made, but otherwise all's working well. My assembler is kept up to date at the same time which means adding a new instruction takes about 10 minutes before I can actually start debugging it, but at least I've got it working (the assembler).

    So I was wondering which instruction(s) I should implement next. I guess it would be logical to start working on sub routine call / ret since I have the jumps working. I still need to get the maths & logic instructions implemented too.

    Thoughts?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  2. #2
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    What about implementing a "loop" instruction? IA32 provides you "loop label" instruction which may be implemented three machine instructions.
    Code:
     loop start_of_code
    means
    Code:
     dec cx
     cmp cx,0
     jnz start_of_code
    So, instead of writing three lines, a programmer using your assembler will use a single instruction.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    How long is a piece of string?

    You can keep adding more and more instructions to suit, but at what point do you stop?
    Some processors have very exotic instructions for all sorts of purposes.

    Are you for example going with "RISC" or "CISC" architecture emulation?
    Study the instruction sets of say the x86 and the ARM processors (one is CISC, the other is RISC)

    Or maybe optimise the instruction set for say a DSP.

    Example instructions
    - arithmetic + - * / %
    - logical & | ^ ~
    - bitwise << >>

    > if GT is set
    What about LE and GE ?

  4. #4
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    >> What about LE and GE ?

    Forgot about those.

    Sorry I just realised how much a waste of time this thread was. I'll do some studying on each.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  5. #5
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Right I've done some research on RISC CISC and MISC, and I think I'm swaying towards RISC. Re-write #4 of my VM offically starts in about 20 minutes.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-20-2007, 07:55 PM
  2. Implement "Whats This" using Win32
    By hemanth.balaji in forum Windows Programming
    Replies: 1
    Last Post: 05-29-2005, 06:03 AM
  3. use C to implement all C++ features?
    By CALVIN in forum C++ Programming
    Replies: 15
    Last Post: 11-12-2002, 09:02 PM
  4. Can't Implement Tabbing
    By Invincible in forum Windows Programming
    Replies: 10
    Last Post: 02-27-2002, 05:09 AM
  5. How To Implement ToolBar ?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 09-28-2001, 11:29 AM