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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:52:07+00:00 2026-06-13T22:52:07+00:00

posted below is the code I have for a simple y86 assembly program. Given

  • 0

posted below is the code I have for a simple y86 assembly program. Given two integers, it should print out the larger of the two. To the right of each line I have an equivalent C translation.

# I ask about the need for a first line comment below.
rdint   %eax          # scanf("%d", &a);
rdint   %ebx          # scanf("%d", &b);
rrmovl  %eax, %ecx    # c = a;
subl    %ebx, %ecx    # c = a - b;
jge     ALarger       # if (c >= 0) { goto ALarger };
wrint   %ebx          # printf("%d", b);
jmp     End           # goto End;

ALarger:
wrint   %eax          # printf("%d", a);

End:
irmovl  $10, %ecx     # c = 10;
halt
wrch    %ecx

Using the assembler yas, the resulting .yo file looks like this:

0x000: f118         | # I ask about the need for a first line comment below.
0x002: f208         | rdint   %eax          # scanf("%d", &a);
0x004: f238         | rdint   %ebx          # scanf("%d", &b);
0x006: 2001         | rrmovl  %eax, %ecx    # c = a;
0x008: 6131         | subl    %ebx, %ecx    # c = a - b;
0x00a: 7514000000   | jge     ALarger       # if (c >= 0) { goto ALarger };
0x00f: f338         | wrint   %ebx          # printf("%d", b);
0x011: 7016000000   | jmp     End           # goto End;
                    |
0x016:              | ALarger:
0x016: f308         | wrint   %eax          # printf("%d", a);
                    |
0x018:              | End:
0x018: 30810a000000 | irmovl  $10, %ecx     # c = 10;
0x01e: 10           | halt
  • This has not been assembled right. I was told that wherever a label is encountered, it is replaced by the address of where it is found in the program. If the first number entered is larger, the instruction at line 0x00a is 7514000000. This is telling the program counter to go to line 0x014 (a line that doesn’t even exist) when it should be telling it to go to 0x016. The same problem exists for line 0x011. Why is this happening?
  • When I assemble the program using the address lines instead of labels, the result is printed, however the newline is not. How can I fix this?
  • Finally, a minor question: If I did not have a comment as the first line, the first line of code is ignored. Is this supposed to happen?

Thank you for your time, I look forward to any answers you can provide.

  • 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-13T22:52:08+00:00Added an answer on June 13, 2026 at 10:52 pm

    YAS requires a new-line after the last line in order to build correct yo code. See http://y86tutoring.wordpress.com/2012/11/06/yas-no-halt-for-the-wicked/ for details.

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

Sidebar

Related Questions

The code pasted below is a simple JSF program, with an idea of having
I'm sure this is something really simple... I have the code below... <script> function
I have a plot (sample code pasted below) that I am trying to add
I have posted an example below and the desired result . I saw a
I have posted my class below and with sample data. I need to pass
I have created two simple files in php. first file (i.e. input.php ): Created
I have the code below (a bare-bones version of Nehe tutorial 1 ported to
Note there's a lot of code posted below but its mostly all the same,
I have a simple test program in C to scramble an array of values
The code pasted below was taken from Javadocs on HttpURLConnection . I get the

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.