1

I'm writing an Intel 8080 Disassembler when I came across this problem.

Here's the code:

int 8080disassemble(unsigned char *cbuffer, int pc){
    unsigned char* code=&cbuffer[pc];
    int opbytes=1;
    printf("%04x ",pc);
    switch(*code){
        case 0x00:printf("NOP");
            break;
        case 0x01:printf("LXI B,#$%02x%02x",code[2],code[1]);opbytes=3;
            break;
        case 0x02:printf("STAX B");
            break;
        case 0x03:printf("INX B");
            break;
        case 0x04:printf("INR B");
            break;
        case 0x05:printf("DCR B");
            break;
        case 0x06:printf("MVI B,#$%02x",code[1]);opbytes=2;
            break;
    }
}

It's a header file, that's why there is no includings.

Thanks!

I tried making it a pointer but didn't work

yoidog
  • 11
  • 1
  • It's generally not a good idea to define functions in header files. See: [How do you define functions in header files?](https://stackoverflow.com/q/49099976/13843268). – sj95126 Nov 30 '22 at 14:54
  • 1
    Function names can't start with a digit. You could rename the following function to `disassemble8080`. Also, remember to post the error when asking for help :) – R1D3R175 Nov 30 '22 at 14:54
  • Identifier naming in C is typically introduced in the very first chapters of any beginner learning material... – Lundin Nov 30 '22 at 14:57
  • Related: [Why can't variable names start with numbers?](https://stackoverflow.com/q/342152/4284627) (that's tagged as C++, but it applies to C as well) – Donald Duck Nov 30 '22 at 15:05

1 Answers1

4

Identifiers in C (such as functions and variable names) are not allowed to start with a digit. The compiler is trying to parse 8080disassemble as a number instead, and gets confused when it reaches the d.

Choose a different name for your function, such as perhaps cpu_8080_disassemble or disassemble_8080.

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82