+ Reply to Thread
Results 1 to 6 of 6

Thread: Undocumented ZCPU Instructions

  1. #1
    Wirererer CCFreak2K's Avatar
    Join Date
    Apr 2007
    Posts
    111

    Lightbulb Undocumented ZCPU Instructions

    Ever wondered what those "reserved" instructions did in the ZCPU? Wonder no more! The undocumented nature of these instructions usually means one of two things: either A) Black_Phoenix was too lazy to update the documentation for these instructions, or B) the instructions are currently not working as designed. Some of the instructions ARE documented in the code, so they may or may not actually be working; however, these instructions should be considered incomplete and thier use should be avoided until they are properly documented. Some aren't even recognized by the mneumonic-opcode table yet. And without further ado, the list of lost instructions:

    Opcode: 016
    Mnemonic: RD X,Y
    Function: X = MEMORY[Y]
    Observation: Seems to read the byte at memory[Y] and put it into X.

    Opcode: 017
    Mnemonic: WD X,Y
    Function: MEMORY[X] = Y
    Observation: Opposite of RD.

    Opcode: 046
    Mnemonic: STD
    Function:
    Observation: Enables debug mode. This causes the CPU to spew its state into the console on every cycle.

    Opcode: 072
    Mnemonic: CJMP X
    Function:
    Observation: The code is identical to CALL.

    Opcode: 100
    Mnemonic: STATESTORE X
    Function:
    Observation: Same as PUSHA (see below), except it writes the registers to the pointer given in X instead of in the stack.

    Opcode: 109
    Mnemonic: STATERESTORE X
    Function:
    Observation: Opposite of STATESTORE.

    Opcode: 113
    Mnemonic: RLADD
    Function:
    Observation: Puts LADD into EAX. This was presumably obsoleted by CPUGET.

    Opcode: 114
    Mnemonic: PUSHA
    Function:
    Observation: Pushes all of the GP registers (EAX-EDX,EDI/SI/BP/SP) onto the stack in one fell swoop.

    Opcode: 115
    Mnemonic: POPA
    Function:
    Observation: Opposite of PUSHA. ESP is not POPped here, so this pair of instructions is obviously broken right now.

    Opcode: 127
    Mnemonic: BLOCK X,Y
    Function: SETUP_DATA_BLOCK([X..X+Y-1])
    Observation: Sets the BLOCKSTART and BLOCKSIZE registers to these values, and otherwise does nothing else.

    Opcode: 128
    Mnemonic: CMPAND X,Y
    Function: CMPR = CMPR AND (X - Y)
    Observation: Sets CMPR to the non-absolute difference between X and Y if CMPR is not zero.

    Opcode: 129
    Mnemonic: CMPOR X,Y
    Function: CMPR = CMPR OR (X - Y)
    Observation: Same as above, except only acts if CMPR IS zero.

    Opcode: 130
    Mnemonic: MSHIFT X
    Function: SHIFT DATA (see lua code)
    Observation: Seems to move a whole block of data in memory, with ESI being the starting point and X being the size. It also takes a second param, but this isn't documented. I'm guessing this is like MCOPY.

    Opcode: 131
    Mnemonic: SMAP X,Y
    Function: PAGE[X].MappedTo = Y
    Observation: This one looks like it -may- be one of the instructions relating to virtual memory that I've been asking for. It maps page X to page Y so reading/writing page X means page Y is read/written instead.

    Opcode: 132
    Mnemonic: GMAP X,Y
    Function: X = PAGE[Y].MappedTo
    Observation: Puts what page Y is mapped to into X.

    Opcode: 133
    Mnemonic: RSTACK X,Y
    Function: X = STACK[Y]
    Observation: Reads a value from memory[SS+Y] into X. Presumably setting Y to ESP lets you read the current top value.

    Opcode: 134
    Mnemonic: SSTACK X,Y
    Function: STACK[X] = Y
    Observation: Opposite of above. Both these instructions let you read/write the stack in a "controlled" manner without PUSHing/POPping.

    Opcode: 138
    Mnemonic: BREAKPOINT
    Function:
    Observation: Causes execution in EmuFox to stop (sets clk to 0 technically). Does nothing in Garry's Mod.

    Opcode: 139
    Mnemonic: CLD
    Function:
    Observation: Opposite of STD.

    NOTE TO PEDANTIC AND INSUFFERABLE FAGGOTS (such as TomyLobo): "Observation" is what I perceive the code to do and may or may not reflect what the code actually does or is intended to do.
    Last edited by CCFreak2K; 01-16-2010 at 05:52 AM. Reason: Changed observation for POPA.

  2. #2
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,662
    Blog Entries
    1

    Default Re: Undocumented ZCPU Instructions

    Nice! More documentation is best for the more advanced wire entities.

    Quote Originally Posted by CCFreak2K View Post
    NOTE TO PEDANTIC AND INSUFFERABLE FAGGOTS (such as TomyLobo): "Observation" is what I perceive the code to do and may or may not reflect what the code actually does or is intended to do.
    I lol'd hard

  3. #3
    Wire Amateur Manic's Avatar
    Join Date
    May 2009
    Posts
    85

    Default Re: Undocumented ZCPU Instructions

    Quote Originally Posted by CCFreak2K View Post
    Opcode: 046
    Mnemonic: STD
    Function:
    Observation: Enables debug mode. This causes the CPU to spew its state into the console on every cycle.

    Opcode: 139
    Mnemonic: CLD
    Function:
    Observation: Opposite of STD.
    So, to counteract STDs we need more CoLDs. Interesting

  4. #4
    Wire Sofaking Fizyk's Avatar
    Join Date
    Jun 2008
    Location
    Łomianki, Poland
    Posts
    740
    Blog Entries
    1

    Default Re: Undocumented ZCPU Instructions

    I would say it's not POPA that is broken, but rather PUSHA, if it really pushes ESP. Pushing ESP makes no sense, neither does popping (these operations use ESP to determine where to push values or pop them from).

    My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
    My tutorials: applyTorque - Quaternions - PID controllers
    Some other things I made: FT Chip - RK4 Solar System

  5. #5
    That furred thing Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    3,565

    Default Re: Undocumented ZCPU Instructions

    Quote Originally Posted by Fizyk View Post
    I would say it's not POPA that is broken, but rather PUSHA, if it really pushes ESP. Pushing ESP makes no sense, neither does popping (these operations use ESP to determine where to push values or pop them from).
    It pops ESP, but doesn't set it
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5

  6. #6
    Wire Amateur WhiteWolf's Avatar
    Join Date
    Jan 2010
    Location
    North Carolina, USA
    Posts
    38

    Default Re: Undocumented ZCPU Instructions

    If I've read documentation correctly, pushing values from registers takes that value out of the register. Or is it simply this?:

    Code:
    mov [SS+ESP],esp

+ Reply to Thread

Similar Threads

  1. ZC32 (ZCPU C compiler)
    By Black Phoenix in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 45
    Last Post: 03-29-2011, 06:10 AM
  2. zCPU emulator!
    By dnifan in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 160
    Last Post: 12-03-2010, 04:09 PM
  3. zCPU bug - int/iret
    By Fizyk in forum Bug Reports
    Replies: 8
    Last Post: 07-21-2008, 08:32 AM
  4. ZCPU problem
    By wokkel in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 0
    Last Post: 11-10-2007, 06:00 AM
  5. give me ideas and instructions
    By gmod newb(wont be soon) in forum Ideas & Suggestions
    Replies: 1
    Last Post: 09-09-2007, 01:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots