webengine/wmlengine/src/script/src/scr_opcodes.c
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 1999 - 2001 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19  /* 
       
    20    $Workfile: scr_opcodes.c $
       
    21 
       
    22     Purpose:
       
    23 
       
    24       Inline parameters have been used to optimally pack information into as
       
    25       few bytes as possible.  Therefore the opcodes types are:
       
    26       1XXPPPPP  ==> type0
       
    27       010XPPPP  ==> type1
       
    28       011XXPPP  ==> type2
       
    29       00XXXXXX  ==> type3
       
    30       This file parses the opcode and return its type and any parameters/instrunctions
       
    31       that has been packed with it.
       
    32  */
       
    33         
       
    34 #include "scr_defs.h"
       
    35 
       
    36 void parse_opcode(NW_Byte *opcode, NW_Byte *param)
       
    37 {
       
    38   /* 1XXPPPP */
       
    39   if ((*opcode & 0x80) == 0x80) {
       
    40     *param  = (NW_Byte)(*opcode & 0x1F);
       
    41     *opcode = (NW_Byte)(*opcode & 0xE0);
       
    42   }
       
    43 
       
    44   /* 010XPPPP */
       
    45   else if ((*opcode & 0xE0) == 0x40) {
       
    46     *param  = (NW_Byte)(*opcode & 0x0F);
       
    47     *opcode = (NW_Byte)(*opcode & 0xF0);
       
    48   }
       
    49 
       
    50   /* 011XXPPP */
       
    51   else if ((*opcode & 0xE0) == 0x60 ) {
       
    52     *param  = (NW_Byte)(*opcode & 0x07);
       
    53     *opcode = (NW_Byte)(*opcode & 0x78);
       
    54   }
       
    55 }