Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:38:05+00:00 2026-06-17T06:38:05+00:00

I am converting 32-bit and 64-bit assembly language files from gas to MASM format,

  • 0

I am converting 32-bit and 64-bit assembly language files from gas to MASM format, and ran across an instruction in my code that seems completely problematic. What I mean is, I see no way the assembler can know what size the operand is, whether the instruction fetches 8, 16, 32 or 64 bits from memory to perform the compare. Here is the instruction:

  • cmp $0, 8(%rsp)

If the instruction had been one of the following, the assembler could have figured out the size of the memory operand to fetch and compare based upon the register:

  • cmp %rax, 8(%rsp)
  • cmp %eax, 8(%rsp)
  • cmp %ax, 8(%rsp)

I would have thought that the instruction needs to be cmpb, cmpw, cmpl, cmpq… but no, my program assembles it fine with just cmp instruction. Unfortunately, I don’t remember what this code is doing, and it is very non-obvious… so the easier way to resolve this is to know what the instruction is doing.

Anyone know? Anyone understand why this syntax (with operand size/type unspecified) is even allowed with an immediate operand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:38:06+00:00Added an answer on June 17, 2026 at 6:38 am

    It must have some kind of default. I tried on my machine, which says as is:

    Apple Inc version cctools-836, GNU assembler version 1.38
    

    And I get these results:

    $ cat example.s 
        cmp $0, 8(%rsp)
    $ make example.o
    as   -o example.o example.s
    $ otool -tV example.o
    example.o:
    (__TEXT,__text) section
    0000000000000000    cmpl    $0x00,0x08(%rsp)
    

    So on my machine, it picked cmpl. Using gcc rather than as gave me the same results, but using clang produced the error you expect:

    $ clang -c example.s 
    example.s:1:2: error: ambiguous instructions require an explicit suffix (could be 'cmpb', 'cmpw', 'cmpl', or 'cmpq')
     cmp $0, 8(%rsp)
     ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While converting from RSpec to Minitest I ran into a slight issue that Google
I have a bit of code that I have been tasked with converting to
I'm currently busy converting my code to ARC and ran into a little bit
Since converting my project to ARC, it seems the analyzer is a bit in
I'm converting some assembly code to C to be able to use it with
I'm working on converting a bit of code to SSE, and while I have
I have this sample code for converting 32 bit integers to ip addresses. #include
I'm converting an app to work in 64-bit. The Apple docs state that the
I have a problem converting a 32-bit to 64-bit code using the lsaapi.pas unit
I need a bit of help with converting routing from Rails 2 to Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.