mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
initate work of a CPUtranslator, example M68k to Intel. it is writen so not only M68k can be added. it does not work at all. it is a ground layout how I should code it.
svn path=/trunk/; revision=25251
This commit is contained in:
parent
1282be6796
commit
39436f3008
8 changed files with 492 additions and 0 deletions
27
rosapps/devutils/cputointel/CpuToIntel.c
Normal file
27
rosapps/devutils/cputointel/CpuToIntel.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "m68k/m68k.h"
|
||||
#include "misc.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
printf("Usage :\n");
|
||||
printf(" -cpu m68000 : convert motorala 68000/68008 to intel asm \n");
|
||||
printf(" -cpu m68010 : convert motorala 68010 to intel asm \n");
|
||||
printf(" -cpu m68020 : convert motorala 68020 to intel asm \n");
|
||||
printf(" -cpu m68030 : convert motorala 68030 to intel asm \n");
|
||||
printf(" -cpu m68040 : convert motorala 68040 to intel asm \n");
|
||||
printf("--------------------------------------------------------------\n");
|
||||
printf(" -inBin filename : the bin file you whant convert\n");
|
||||
printf(" -OutAsm filename : the Asm file you whant create\n");
|
||||
printf("--------------------------------------------------------------\n");
|
||||
printf("More cpu will be added with the time or options, this is \n");
|
||||
printf("version 0.0.1 of the cpu to intel converter writen by \n");
|
||||
printf("Magnus Olsen (magnus@greatlord.com), it does not do anything \n");
|
||||
printf("yet, more that basic desgin how it should be writen. \n");
|
||||
printf("Copyright 2006 by Magnus Olsen, licen under GPL 2.0 for now. \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
15
rosapps/devutils/cputointel/cputointel.rbuild
Normal file
15
rosapps/devutils/cputointel/cputointel.rbuild
Normal file
|
@ -0,0 +1,15 @@
|
|||
<module name="cputointel" type="win32cui" installbase="system32" installname="cputointel.exe" stdlib="host">
|
||||
<include base="cputointel">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x0501</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
|
||||
<file>CpuToIntel.c</file>
|
||||
<file>misc.c</file>
|
||||
|
||||
<file>m68k/M68kBrain.c</file>
|
||||
<file>m68k/M68kopcode.c</file>
|
||||
|
||||
</module>
|
209
rosapps/devutils/cputointel/m68k/M68kBrain.c
Normal file
209
rosapps/devutils/cputointel/m68k/M68kBrain.c
Normal file
|
@ -0,0 +1,209 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "M68kBrain.h"
|
||||
#include "m68k.h"
|
||||
#include "../misc.h"
|
||||
|
||||
/* retun
|
||||
* 0 = Ok
|
||||
* 1 = unimplemt
|
||||
* 2 = Unkonwn Opcode
|
||||
* 3 = can not open read file
|
||||
* 4 = can not open write file
|
||||
* 5 = can not seek to end of read file
|
||||
* 6 = can not get the file size of the read file
|
||||
* 7 = read file size is Zero
|
||||
* 8 = can not alloc memory
|
||||
* 9 = can not read file
|
||||
*/
|
||||
|
||||
CPU_INT M68KBrain(char *infileName, char *outputfileName, CPU_UNINT BaseAddress)
|
||||
{
|
||||
FILE *infp;
|
||||
FILE *outfp;
|
||||
CPU_BYTE *cpu_buffer;
|
||||
CPU_UNINT cpu_pos = 0;
|
||||
CPU_UNINT cpu_oldpos;
|
||||
CPU_UNINT cpu_size=0;
|
||||
CPU_INT cpuint;
|
||||
CPU_INT retcode = 0;
|
||||
CPU_INT retsize;
|
||||
|
||||
/* Open file for read */
|
||||
if (!(infp = fopen(infileName,"RB")))
|
||||
{
|
||||
printf("Can not open file %s\n",infileName);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Open file for write */
|
||||
if (!(outfp = fopen(outputfileName,"WB")))
|
||||
{
|
||||
printf("Can not open file %s\n",outputfileName);
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* Load the binary file to a memory buffer */
|
||||
fseek(infp,0,SEEK_END);
|
||||
if (!ferror(infp))
|
||||
{
|
||||
printf("error can not seek in the read file");
|
||||
fclose(infp);
|
||||
fclose(outfp);
|
||||
return 5;
|
||||
}
|
||||
|
||||
/* get the memory size buffer */
|
||||
cpu_size = ftell(infp);
|
||||
if (!ferror(infp))
|
||||
{
|
||||
printf("error can not get file size of the read file");
|
||||
fclose(infp);
|
||||
fclose(outfp);
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (cpu_size==0)
|
||||
{
|
||||
printf("error file size is Zero lenght of the read file");
|
||||
fclose(infp);
|
||||
fclose(outfp);
|
||||
return 7;
|
||||
}
|
||||
|
||||
/* alloc memory now */
|
||||
if (!(cpu_buffer = (unsigned char *) malloc(cpu_size)))
|
||||
{
|
||||
printf("error can not alloc %uld size for memory buffer",cpu_size);
|
||||
fclose(infp);
|
||||
fclose(outfp);
|
||||
return 8;
|
||||
}
|
||||
|
||||
/* read from the file now in one sweep */
|
||||
fread(cpu_buffer,1,cpu_size,infp);
|
||||
if (!ferror(infp))
|
||||
{
|
||||
printf("error can not read file ");
|
||||
fclose(infp);
|
||||
fclose(outfp);
|
||||
return 9;
|
||||
}
|
||||
fclose(infp);
|
||||
|
||||
/* now we start the process */
|
||||
while (cpu_pos<cpu_size)
|
||||
{
|
||||
cpu_oldpos = cpu_pos;
|
||||
|
||||
cpuint = cpu_buffer[cpu_pos];
|
||||
|
||||
/* Abcd */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Abcd))) == ConvertBitToByte(cpuint_table_Abcd))
|
||||
{
|
||||
retsize = M68k_Abcd(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* Add */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Add))) == ConvertBitToByte(cpuint_table_Add))
|
||||
{
|
||||
retsize = M68k_Add(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* Addi */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Addi))) == ConvertBitToByte(cpuint_table_Addi))
|
||||
{
|
||||
retsize = M68k_Addi(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* Addq */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Addq))) == ConvertBitToByte(cpuint_table_Addq))
|
||||
{
|
||||
retsize = M68k_Addq(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* Addx */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Addx))) == ConvertBitToByte(cpuint_table_Addx))
|
||||
{
|
||||
retsize = M68k_Addx(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* And */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_And))) == ConvertBitToByte(cpuint_table_And))
|
||||
{
|
||||
retsize = M68k_Add(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* Andi */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_Andi))) == ConvertBitToByte(cpuint_table_Andi))
|
||||
{
|
||||
retsize = M68k_Andi(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
/* AndToCCR */
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_AndToCCRF))) == ConvertBitToByte(cpuint_table_AndToCCRF))
|
||||
{
|
||||
cpuint = cpu_buffer[cpu_pos+1];
|
||||
if ((cpuint - (cpuint & GetMaskByte(cpuint_table_AndToCCRS))) == ConvertBitToByte(cpuint_table_AndToCCRS))
|
||||
{
|
||||
cpu_pos++;
|
||||
retsize = M68k_AndToCCR(outfp, cpu_buffer, cpu_pos, cpu_size, BaseAddress);
|
||||
if (retsize<0)
|
||||
retcode = 1;
|
||||
else
|
||||
cpu_pos += retsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
cpuint = cpu_buffer[cpu_pos];
|
||||
}
|
||||
}
|
||||
|
||||
/* Found all Opcode and breakout and return no error found */
|
||||
if (cpu_pos >=cpu_size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if we have found a cpu opcode */
|
||||
if (cpu_oldpos == cpu_pos)
|
||||
{
|
||||
if (retcode == 0)
|
||||
{
|
||||
/* no unimplement error where found so we return a msg for unknown opcode */
|
||||
printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
|
||||
retcode = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Erorro Found ? */
|
||||
if (retcode!=0)
|
||||
{
|
||||
/* Erorro Found break and return the error code */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retcode;
|
||||
}
|
23
rosapps/devutils/cputointel/m68k/M68kBrain.h
Normal file
23
rosapps/devutils/cputointel/m68k/M68kBrain.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include "../misc.h"
|
||||
|
||||
CPU_BYTE cpuint_table_Abcd[16] = {1,1,1,1,2,2,2,1,0,0,0,0,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Add[16] = {1,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Addi[16] = {0,0,0,0,0,1,1,0,2,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Addq[16] = {0,1,0,1,2,2,2,0,2,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Addx[16] = {1,1,0,1,2,2,2,1,2,2,0,0,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_And[16] = {1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Andi[16] = {0,0,0,0,0,0,1,0,2,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_AndToCCRF[16] = {0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0};
|
||||
CPU_BYTE cpuint_table_AndToCCRS[16] = {0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2};
|
||||
CPU_BYTE cpuint_table_Asl[16] = {1,1,1,0,2,2,2,0,2,2,2,0,0,2,2,2};
|
||||
CPU_BYTE cpuint_table_Asr[16] = {1,1,1,0,2,2,2,1,2,2,2,0,0,2,2,2};
|
||||
|
||||
|
||||
CPU_BYTE table_Rx[16] = {0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0};
|
||||
CPU_BYTE table_RM[16] = {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0};
|
||||
CPU_BYTE table_Ry[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1};
|
||||
CPU_BYTE table_Opmode[16] = {0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0};
|
||||
CPU_BYTE table_Mode[16] = {0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0};
|
||||
CPU_BYTE table_Size[16] = {0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0};
|
||||
|
150
rosapps/devutils/cputointel/m68k/M68kopcode.c
Normal file
150
rosapps/devutils/cputointel/m68k/M68kopcode.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "m68k.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
CPU_INT M68k_Abcd(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Abcd unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
CPU_INT opmode;
|
||||
CPU_INT mode;
|
||||
CPU_INT Rx;
|
||||
CPU_INT Ry;
|
||||
//CPU_INT cpuint;
|
||||
|
||||
opmode = ConvertBitToByte(table_Opmode);
|
||||
mode = ConvertBitToByte(table_Mode);
|
||||
Rx = ConvertBitToByte(table_Rx);
|
||||
Ry = ConvertBitToByte(table_Ry);
|
||||
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
if (opmode == 0x00)
|
||||
{
|
||||
/* <ea> + Dn -> Dn */
|
||||
printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
|
||||
|
||||
}
|
||||
|
||||
if (opmode == 0x01)
|
||||
{
|
||||
/* <ea> + Dn -> Dn */
|
||||
printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x02)
|
||||
{
|
||||
/* <ea> + Dn -> Dn */
|
||||
printf(";Add unimplement of \"<ea> + Dn -> Dn\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x03)
|
||||
{
|
||||
/* <ea> + An -> An */
|
||||
printf(";Add unimplement of \"<ea> + An -> An\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x04)
|
||||
{
|
||||
/* Dn + <ea> -> <ea> */
|
||||
printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x05)
|
||||
{
|
||||
/* Dn + <ea> -> <ea> */
|
||||
printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x06)
|
||||
{
|
||||
/* Dn + <ea> -> <ea> */
|
||||
printf(";Add unimplement of \"Dn + <ea> -> <ea>\" \n");
|
||||
}
|
||||
|
||||
if (opmode == 0x07)
|
||||
{
|
||||
/* <ea> + An -> An */
|
||||
printf(";Add unimplement of \"<ea> + An -> An\" \n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Addi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Addi unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Addq(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Addq unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Addx(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Addx unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_And(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";And unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Andi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Andi unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_AndToCCR(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";AndToCCR unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Asl(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Asl unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT M68k_Asr(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress)
|
||||
{
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Asr unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
20
rosapps/devutils/cputointel/m68k/m68k.h
Normal file
20
rosapps/devutils/cputointel/m68k/m68k.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
#include "../misc.h"
|
||||
|
||||
CPU_INT M68k_Abcd(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Add(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Addi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Addq(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Addx(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_And(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Andi(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_AndToCCR(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Asl(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
CPU_INT M68k_Asr(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress);
|
||||
|
||||
extern CPU_BYTE table_Rx[16];
|
||||
extern CPU_BYTE table_RM[16];
|
||||
extern CPU_BYTE table_Ry[16];
|
||||
extern CPU_BYTE table_Opmode[16];
|
||||
extern CPU_BYTE table_Mode[16];
|
||||
extern CPU_BYTE table_Size[16];
|
34
rosapps/devutils/cputointel/misc.c
Normal file
34
rosapps/devutils/cputointel/misc.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
/* Conveting bit array to a int byte */
|
||||
CPU_UNINT ConvertBitToByte(CPU_BYTE *bit)
|
||||
{
|
||||
CPU_UNINT Byte = 0;
|
||||
CPU_UNINT t;
|
||||
|
||||
for(t=15;t>0;t--)
|
||||
{
|
||||
if (bit[15-t] != 2)
|
||||
Byte = Byte + (bit[15-t]<<t);
|
||||
}
|
||||
return Byte;
|
||||
}
|
||||
|
||||
/* Conveting bit array mask to a int byte mask */
|
||||
CPU_UNINT GetMaskByte(CPU_BYTE *bit)
|
||||
{
|
||||
CPU_UNINT MaskByte = 0;
|
||||
CPU_UNINT t;
|
||||
|
||||
for(t=15;t>0;t--)
|
||||
{
|
||||
if (bit[15-t] == 2)
|
||||
{
|
||||
MaskByte = MaskByte + ( (bit[15-t]-1) <<t);
|
||||
}
|
||||
}
|
||||
return MaskByte;
|
||||
}
|
14
rosapps/devutils/cputointel/misc.h
Normal file
14
rosapps/devutils/cputointel/misc.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
#define CPU_UNINT unsigned int
|
||||
#define CPU_INT int
|
||||
|
||||
#define CPU_BYTE unsigned char
|
||||
|
||||
/* Prototypes for misc stuff */
|
||||
|
||||
|
||||
/* Convert Bit index to int */
|
||||
CPU_UNINT ConvertBitToByte(CPU_BYTE *bit);
|
||||
CPU_UNINT GetMaskByte(CPU_BYTE *bit);
|
||||
|
||||
|
Loading…
Reference in a new issue