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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:08:30+00:00 2026-06-07T06:08:30+00:00

I have to translate this C code to assembly code: #include <stdio.h> int main(){

  • 0

I have to translate this C code to assembly code:

 #include <stdio.h>

 int main(){

 int a, b,c;
 scanf("%d",&a);
 scanf("%d",&b);
 if (a == b){
   b++;
 } 
 if (a > b){
  c = a;
  a = b;
  b = c;    
 }
 printf("%d\n",b-a);
 return 0;
 }  

My code is below, and incomplete.

    rdint %eax        # reading a
    rdint %ebx        # reading b
    irmovl $1, %edi

    subl %eax,%ebx
    addl %ebx, %edi
    je Equal


    irmov1 %eax, %efx  #flagged as invalid line
    irmov1 %ebx, %egx
    irmov1 %ecx, %ehx
    irmovl $0, %eax
    irmovl $0, %ebx
    irmovl $0, %ecx

    addl %eax, %efx    #flagged as invalid line
    addl %ebx, %egx
    addl %ecx, %ehx



    halt

Basically I think it is mostly done, but I have commented next to two lines flagged as invalid when I try to run it, but I’m not sure why they are invalid. I’m also not sure how to do an if statment for a > b. I could use any suggestions from people who know about y86 assembly language.

  • 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-07T06:08:32+00:00Added an answer on June 7, 2026 at 6:08 am

    From what I can find online (1, 2), the only supported registers are: eax, ecx, edx, ebx, esi, edi, esp, and ebp.

    You are requesting non-existent registers (efx and further).

    Also irmov is for moving an immediate operand (read: constant numerical value) into a register operand, whereas your irmov1 %eax, %efx has two register operands.

    Finally, in computer software there’s a huge difference between the character representing digit “one” and the character representing letter “L”. Mind your 1’s and l’s. I mean irmov1 vs irmovl.

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

Sidebar

Related Questions

I have this code below, and I want to translate it to ASM, to
I have this code: $str = '(Test)'; $final = preg_replace('/\[translate=([a-z]{2})(.*)\]'.preg_quote($matches[3][$i]).'\[\/translate(.*)\]/',$str,$final,-1,$ct); It handles a situation
Can someone please translate this high-level code into IA-32 assembly without using any global
I have url http://translate.google.ru/translate_a/t?client=x&text=ввійти вийти&sl=ua&tl=en If you will go through this link in response
I have this code that works in FreePascal under Windows and need to translate
I have never used ruby but need to translate this code to java. Can
I have to translate this code: <!--[if IE 7]> <link rel=stylesheet type=text/css href=css/ie7-style.css />
I have some jquery code which I am trying to translate to YUI. I
I am trying to translate a C program into MIPS assembly code In my
i have this code that can do fast search on database. it works excellent

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.