Как я могу исправить этот код, это код alu
#include <stdio.h> #include <stdlib.h> //defineOpCodes int OR(int A, int B); int AddSub(int A,int B, int OpCode); int mux(short In1, short In2, short Sel); int AND(int A,int B); int main(){ #define OP_ADD 0x00 #define OP_SUB 0x01 #define OP_LEFT 0x02 #define OP_RIGHT 0x03 int A = 0b0000000001111011; int B = 0b0000000001100100; int Result = 0; char operation[4]; printf ("Which operation would you like? ADD/SUB/OR/AND > "); sscanf("%s",operation); int opcode=0; if (operation == "ADD") int OpCode = ADD( A, B); else if(operation == "SUB") int OpCode = SUB(A ,B); else if(operation == "AND") OpCode = 0; else if (operation == "OR") OpCode = 0; int z = AddSub(int A, int B, int OpCode); int AndOut = AND(int A,int B); int OrOut = OR(int A,int B); int MuxOut = mux(AndOut, OrOut, s0); int MuxOut2 = mux(MuxOut1,z, s1); return MuxOut2; } // Input and Output Registers int A = 0; int B = 0; int Result = 0; // Status registers int Z = 0; // bitstring.Bits(uint=bytes, length=8) int Ovf = 0; // Arithemtic and Logical Unit int AddSub(int A,int B, int OpCode){ if (OpCode == ADD) Sum = A + B; else Sum = A - B; //set up the Z flag. Ignore the Ovf right flag for now if (Sum == 0) Z = 1; else Z = 0; return Sum, Z; } // 2-to-1 Multiplexer int mux(short In1, short In2, short Sel) { int Out; if (Sel == 0) Out = In1; else Out = In2; return(Out); } // AND Gate int AND(A, B){ return A&B; } //OR Gate int OR(A, B){ return A|B; }
Что я уже пробовал:
Я не знаю, где ошибка, если кто-то может мне помочь
David_Wimbley
Какую ошибку вы получаете, Если вы ожидаете, что кто-то скопирует и вставит код, чтобы увидеть, что это за ошибка, вы, скорее всего, не получите большой помощи.
Вы должны четко сформулировать свою проблему, указать, в чем заключается ошибка, предоставив трассировку стека или подробное описание поведения, которое вы видите, и то, что он должен был делать, чего вы не понимаете.
Просто говоря: "я не знаю, где находится Мисаке", и ожидая, что мы будем делать работу ног, вы не очень-то поможете.
ZurdoDev
Исправьте это, заставив его работать. Чего вы от нас хотите?