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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:09:33+00:00 2026-05-26T02:09:33+00:00

I’m writing a small assembly routine called isOdd, which, as the name implies, returns

  • 0

I’m writing a small assembly routine called isOdd, which, as the name implies, returns if the passed integer is odd, by returning 1 from a % operation.

This is my code so far:

Function prototype: int isOdd( long num )

isOdd:
    save     %sp, -96, %sp  ! Save caller's window

    mov      %i0, %o0       ! Parameter num goes to %o0
    mov      2, %l0         ! 2 goes to local register
    call     .rem           ! Call modulus subroutine
    nop

    mov      %o0, %l0       ! moves the result of the subroutine 
                            ! to output register o0
    ret
    restore

However, I don’t get good output; in fact, it seems like it is just returning whatever value I pass to num, instead of actually doing the modulus operation.

Google hasn’t proved helpful for such a basic question. This is my first assembly code, so I’m pretty unfamiliar with the concept of “registers,” and I think mixing them up is where my error may lie.

Thanks in advance for your help!

  • 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-05-26T02:09:34+00:00Added an answer on May 26, 2026 at 2:09 am

    There are a whole bunch of registers, which you can think of as being in blocks
    of 8. At any one time, three consecutive blocks of 8 registers are visible as
    the current register window, and are labelled as %o0–%o7, %l0–%l7, and
    %i0–%i7. (There is a fourth block of 8 registers, %g0–%g7, which are
    global rather than being a part of the windowing arrangement.)

    When you save or restore, the window moves by two blocks of 8. The
    overlapping block allows for parameter and result passing. The registers
    which are named %o0–%o7 in the caller are the same ones that are named
    %i0–%i7 in the callee. (The two new blocks in the callee are %l0–%l7,
    which are private for local use within that window, and %o0–%o7 which the
    callee can use when it in turn wants to call another function.)

    It’s clearer with a picture:

    :                      :
    +----------------------+
    | Block of 8 registers |      caller's window
    +----------------------+  +----------------------+
    | Block of 8 registers |  |      %i0 - %i7       |    ---------.
    +----------------------+  +----------------------+             | save
    | Block of 8 registers |  |      %l0 - %l7       |             v
    +----------------------+  +----------------------+  +----------------------+
    | Block of 8 registers |  |      %o0 - %o7       |  |      %i0 - %i7       |
    +----------------------+  +----------------------+  +----------------------+
    | Block of 8 registers |              ^             |      %l0 - %l7       |
    +----------------------+      restore |             +----------------------+
    | Block of 8 registers |              `---------    |      %o0 - %o7       |
    +----------------------+                            +----------------------+
    | Block of 8 registers |                                callee's window
    +----------------------+
    :                      :
    

    Your caller places the num argument into %o0 (in its window), then calls
    you. You save to set up a new window, and so you see it in %i0 in your
    window.

    .rem takes two parameters. You place these in your %o0 and %o1 (in your
    window), then call it. It will see them in its %i0 and %i1 (assuming it does
    a save to set up a new window). It puts the answer in its %i0, which is
    your %o0.

    Similarly, you should put your result in your %i0; whoever called you will see it
    in their %o0.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.