Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program accepts an integer between -511 to +511 typed in by user. It works until a valid number is entered, then the program prints

This program accepts an integer between -511 to +511 typed in by user. It works until a valid number is entered, then the program prints the binary version of the number as an integer and follows it by printing the binary representation of the number as a 16-bit floating point number.

Bit 15 is the sign bit.

Bits 14 - 11 is the biased exponent (bias of 7).

Bits 10 - 0 is the mantissa (fractional part). Remember there is an implicit 1 for the fractional part.

You must use subroutines for this program.

To assist you, here is some code that must be used, you must not add any lines of code before the halt instruction.

image text in transcribed

Example input and output.

image text in transcribed

Zero is a special case.

image text in transcribed

When writing assembly language the temptation is to treat most values as globally accessible. The solution to this is to pass parameters and return values on the stack as in higher level languages. For this assignment you may use globally accessible values when that makes sense. You should save all registers (except R0) when you enter a subroutine and restore them on exit. This is not strictly necessary in this assignment because the top-level program doesn't depend on registers maintaining their values. On a related point most programming languages keep all of the code separated from the data. In assembly language that is also a good idea but for this assignment it may be easier if you keep data associated with a subroutine near that subroutine. It makes it easier for you to read and fix your code. Also many of the LC-3 addressing modes limit offsets from the current value of PC to 256 words.

Thank you so much for your time and help!!!

; To 16 bit floating point. ; Take a signed integer in the range -511 to +511 ; Print the value as a 16 bit floating point value as in Assignment 1 ; This program must use subroutines. ; When calling a subroutine, ro is assumed to be changed. ; Any other registers used by the subroutine should be saved and restored (not absolutely necessary but it is good style) .orig x3000 get_number convert_number ; r returns xffff if invalid, otherwise the converted integer r1, r0, #1 start start jsr add brz jsr print_binary; prints r as binary Jsr ; try again if invalid convert float; resul print_binary t in ro sr halt ; To 16 bit floating point. ; Take a signed integer in the range -511 to +511 ; Print the value as a 16 bit floating point value as in Assignment 1 ; This program must use subroutines. ; When calling a subroutine, ro is assumed to be changed. ; Any other registers used by the subroutine should be saved and restored (not absolutely necessary but it is good style) .orig x3000 get_number convert_number ; r returns xffff if invalid, otherwise the converted integer r1, r0, #1 start start jsr add brz jsr print_binary; prints r as binary Jsr ; try again if invalid convert float; resul print_binary t in ro sr halt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions