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

  • SEARCH
  • Home
  • 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 9302499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:16:14+00:00 2026-06-18T23:16:14+00:00

How to compare two words in NASM assembly? consider this code: global start start:

  • 0

How to compare two words in NASM assembly? consider this code:

global start
start:
    mov eax,array
    mov edx,4
    mov ecx,2987074
.LOOP1:
    cmp word [eax],ecx
    je .FOUND
    add eax,4
    sub edx,1
    jz .NOTFOUND
    jmp .LOOP1
.FOUND:
    xor ebx,ebx
    jmp .EXIT
.NOTFOUND:
    mov ebx,1
.EXIT:
    mov eax,1
    int 0x80

array:  
    dd 1137620
    dd 3529469
    dd 2987074
    dd 1111111
    dd 2222222

returns

foo.asm:7: error: mismatch in operand sizes

and changing cmp from cmp word [eax],ecx to cmp word [eax],word ecx

returns:

foo.asm:7: warning: register size specification ignored
foo.asm:7: error: mismatch in operand sizes

I have no idea how to fix this. Can someone explain it?

  • 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-18T23:16:15+00:00Added an answer on June 18, 2026 at 11:16 pm

    cmp word [eax],ecx is wrong because operand sizes don’t match (ecx is a dword, not word). Most x86 instructions with two operands can only work with operands of the same size.

    cmp word [eax],word ecx is wrong because ecx is a dword, not word.

    If you’re coming from the (g)as/gcc world, it’s worth noting that their .word is the machine word and on a 32-bit machine it’s 32-bit. NASM’s word is always 16-bit and its dword is always 32-bit.

    You probably want just cmp [eax], ecx. Since the two operands of cmp must be of the same size, NASM deduces here that the memory operand at address in eax is the same size as the register operand ecx, 32-bit (dword).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make this code work, the idea is to compare two
I need to compare two dictionary values if the types stored are equal, this
I'm trying be able to compare two Strings and identify duplicate words. For example;
I have a form where I can input two words then compare the levenshtein
Is it possible to compare two different strings... Finding common words between the two
I have a question for how to compare two strings. here is the code.
I know how to compare two texts and get all the single words that
How do you compare two strings in Fish (like abc == def in other
How can I compare two dictionaries of different keys, such as the ones below?
I am trying to compare two tools execution time, which I have installed in

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.