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 8087117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:40:15+00:00 2026-06-05T18:40:15+00:00

I’ve been having a lot of trouble figuring this out. So I’m using inline

  • 0

I’ve been having a lot of trouble figuring this out. So I’m using inline Assembly and I’m basically trying to compare a number the user types in using Scanf with the number “$20.”

But I think it’s comparing the location rather than the actual value.

Here is what I have:

asm(
    "main:                                                                                              \n"
    "                                                                                              \n"
    "push $msg                                                                                             \n"
    "call _printf                                                                                              \n"
    "add $4, %esp                                                                                              \n"
    "                                                                                              \n"
    "push $gus                                                                                              \n"
    "push $fmt                                                                                              \n"
    "call _scanf                                                                                              \n"
    "add $8, %esp                                                                                              \n"
    "                                                                                              \n"
    "movl $20, %eax                                                                                         \n"
    "movl $gus, %ebx                                                                                          \n"
    "cmp %eax, %ebx                                                                                             \n"
    "jg lower                                                                                              \n"
    "jl higher                                                                                              \n"
    "                                                                                              \n"
    "lower:                                                                                              \n"
    "push $lss                                                                                              \n"
    "call _printf                                                                                              \n"
    "add $4, %esp                                                                                              \n"
    "jmp next                                                                                              \n"
    "                                                                                              \n"
    "higher:                                                                                              \n"
    "push $gtr                                                                                              \n"
    "call _printf                                                                                              \n"
    "add $4, %esp                                                                                              \n"
    "jmp next                                                                                              \n"
    "                                                                                              \n"
    "next:                                                                                              \n"
    "jmp main                                                                                              \n"
    "ret                                                                                              \n"
    "                                                                                              \n"
    ".section .data                                                                                              \n"
    "msg: .asciz \"Please enter your guess: \"                                                                                              \n"
    "gtr: .asciz \"Higher! \"                                                                                     \n"
    "lss: .asciz \"Lower! \"                                                                               \n"
 //   "crr: .asciz \"Please enter your guess: \"                                                                                              \n"
    "fmt: .asciz \"%d\"                                                                                              \n"
    ".double 100                                                                                             \n"
    ".byte 0                                                                                             \n"
    "gus: .double 100                                                                                             \n"
    ".byte 0                                                                                         \n"
    );

Yes, I know there really isn’t a point in this code for actual use. The purpose of me writing this is really just to figure out how comparisons.

But my problem is, at:

 "movl $20, %eax                                                                                         \n"
"movl $gus, %ebx                                                                                          \n"
"cmp %eax, %ebx  

It’s supposed to compare 20 with the “gus”, or the “guess” the user typed in. But it always says “Lower” no matter what they type in.

  • 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-05T18:40:16+00:00Added an answer on June 5, 2026 at 6:40 pm

    You load the address of gus, not its value, to EBX before comparing.

    Your bigger problem is that you try to do way too much with inline assembly.
    You want to compare in assembly? Very well, compare. But why call printf and scanf and all the rest?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.