error A2008: syntax error :

10,351

As @Michael Petch suggested in the comments, using an older version of MASM (6.15 in my case), and it worked.

Note that if you are using C/CPP code in your project and intend on linking them with the assembly files (as I was doing), you will need to downgrade your C compiler as well. In my case, I changed it from CL (Microsoft C/C++ Optimizing Compiler Version 19.10.25017) to dmc.

Share:
10,351

Related videos on Youtube

ofir dubi
Author by

ofir dubi

Updated on June 04, 2022

Comments

  • ofir dubi
    ofir dubi almost 2 years

    I'm trying to write a bootloader for an OS I'm developing.

    I'm getting a syntax error on the first line.

    Here is my assembly code:

    .286 ; CPU Type
    .model TINY  ; memory of model
    ;---------------------- EXTERNS -----------------------------
    extrn               _BootMain:near     ; prototype of C func
    ;------------------------------------------------------------
    ;------------------------------------------------------------   
    .code 
    org             07c00h         ; for BootSector
    _main:
                    jmp short _start       ; go to main
                    nop
    
    ;----------------------- CODE SEGMENT -----------------------
    _start: 
            cli
            mov ax,cs               ; Setup segment registers
            mov ds,ax               ; Make DS correct
            mov es,ax               ; Make ES correct
            mov ss,ax               ; Make SS correct        
            mov bp,7c00h
            mov sp,7c00h           ; Setup a stack
            sti
                                    ; start the program 
            call           _BootMain
            ret
            END _start
            END _main ; End of program
    

    Here's my compile line:

    "*location*\14.10.25017\bin\HostX86\x86\ML.EXE"  /c StartPoint.asm
    

    The error I'm getting:

    StartPoint.asm(1): error A2008: syntax error : .

    As far as I know, this line shouldn't be a problem.

    Thanks for the help :)

    • Jester
      Jester over 6 years
      .286 is not a valid directive according to msdn. Just delete it.
    • Michael Petch
      Michael Petch over 6 years
      You may wish to consider an older version of MASM or TASM the assembles 16-bit code and 16-bit linker. I also hope you aren't trying to call into 32-bit code.
    • Peter Cordes
      Peter Cordes over 6 years
      Or use NASM, it still assembles 16-bit code just fine, AFAIK. (But uses a different variant of intel-syntax, see stackoverflow.com/tags/intel-syntax/info.
    • ofir dubi
      ofir dubi over 6 years
      deleting the line led to another error: /assembly-fatal-error-lnk1190-invalid-fixup-found-type-0x000‌​1. i ended up using @Michael Petch solution, downloading an older version of MASM, and it worked. Thanks for the quick responce.
  • Peter Cordes
    Peter Cordes over 6 years
    Or you need your OS to switch to 32 or 64-bit mode. Or you could use gcc -m16 to make similar code to -m32 but assemble it for 16-bit mode, so most instructions have operand-size and address-size prefixes. (And thus will only run on a 386 or later.)