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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:37:14+00:00 2026-06-02T07:37:14+00:00

I have an assignment to create a program that converts deci (-32,768 through 32,767)

  • 0

I have an assignment to create a program that converts deci (-32,768 through 32,767) to bin. The output must show all 16 bits. For example, if the input is 120, output should be: 0000000001111000. I can’t figure out how to output 0s and 1s in reverse. When I enter 120 I get: 0001111000000000.
P.S: I’m using Pep/8 assembler and simulator (http://code.google.com/p/pep8-1/), which is available for Mac and PC.
This is what I have so far:

;Pavel; Assignment 3
BR       main                ;Branch to MAIN
num:     .BLOCK  2           ;Input variable
flag:    .BLOCK  2           ;C flag
limit:   .BLOCK  2           ;Loop LIMIT
main:    LDA     0, i        ;Clear Accumulator
         DECI    num, d      ;Input 
loop:    LDA     limit, d    ;Load loop LIMIT
         CPA     16, i       ;Compare LIMIT to 16
         BREQ    exit        ;If LIMIT == 16, branch to EXIT. Done converting.
         LDA     num, d      ;Load NUM
         ASRA                ;Shift NUM to the right (division by 2)
         STA     num, d      ;Store NUM after division
if:      MOVFLGA             ;Load flags to Accumulator
         BRC     else        ;If C == 1, branch to ELSE
         DECO    0, i        ;Output 0
         LDA     limit, d    ;Load LIMIT
         ADDA    1, i        ;Add 1 to LIMIT
         STA     limit, d    ;Store LIMIT
         BR      loop        ;Branch to LOOP
else:    DECO    1, i        ;Output 1
         LDA     limit, d    ;Load LIMIT
         ADDA    1, i        ;Add 1 to LIMIT
         STA     limit, d    ;Store LIMIT
         BR      loop        ;Branch to LOOP
exit:    CHARO   ' ', i      ;Outputs space
         STOP
         .END
  • 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-02T07:37:15+00:00Added an answer on June 2, 2026 at 7:37 am

    You are now shifting right and testing the bit that ends up in carry. What would happen if you shifted the other way?

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

Sidebar

Related Questions

For a school assignment I have to create a C++ program that will create
I was given the assignment to create a program that performs basic set operations.
I've been given an assignment to create a program that might involve a quiz
I have an assignment to create a paint program in Java. I have managed
So I have an assignment that I have to use Tkinter to create a
I have an assignment that I have to create a randomly sized 3D array,
As part of an assignment I need to create a shipping program that checks
I have been trying to create a Main program that calls another program, sending
I have a programming assignment and we are asked to create a program in
I have an assignment to create a GUI using MATLAB GUIDE and am having

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.