コード例 #1
0
ファイル: mainHalt.c プロジェクト: snayski/School-Work
int main()
{
  unsigned int bufferLength;
  unsigned char *buffer = allocateInstructionBuffer(&bufferLength);

  // generate the Intel code for sumVector.obj
  translateBinary("not used!", buffer, bufferLength);
  
  // the trick is to pass the code the address of the buffer,
  // which will be placed into %rsi
  ((void (*)(void*)) buffer)(buffer); 
 
  // the translated code just halted and has no data words, so
  // nothing to look at when it completes.
  printf("The translated code returned.\n");

  return 0;
}
コード例 #2
0
int IRArray::readBinary(){
    for(int i=0; i<3; i++){
        toBinary[i]=0;
    }

    bool check = true;
    while(check){
        for(int i=0; i<3; i++){
            sensorVal[i] = constrain(map(analogRead(sensPins[i]), 350, 400, 1, 0), 0, 1);
        }

        for(int i=0; i<3; i++){
            if(sensorVal[i]) toBinary[i]=1;
            else if(!sensorVal[0]&&!sensorVal[1]&&!sensorVal[2]) check=false; //if all three are 0
        }
    }
    return translateBinary();
}
コード例 #3
0
int main(int argc,char *argv[]) {
    uint64_t length=4096*5;
    uint8_t *buf=allocate_executable_buffer(&length);
    if(length==(uint64_t)(void*)-1) {
        return 11;
    }
    translateBinary(argv[1],buf,length);
    FILE* outfile=NULL;
    outfile=fopen("a.out","w");
    if(!outfile) {
        return 12;
    }
    size_t nbytes=fwrite(buf,1,4096,outfile);
    if(nbytes==(size_t)-1) {
        return 13;
    }
    if(nbytes==(size_t)0) {
        return 14;
    }
    return 0;
}