Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I have this Assembly assignment I have due to tomorrow 23:00 gmt, and I have no clue where to start. Anyone can help me

Hello, I have this Assembly assignment I have due to tomorrow 23:00 gmt, and I have no clue where to start. Anyone can help me with this? We are given a template that ill copypaste below. Thanks!

Description: Store a number to the memory address specified in your assn 3 template. In your program, load that number in a register, and display it to the console as 16-bit twos complement binary (i.e. display the binary value stored in the register, as a sequence of 16 ascii 1 and 0 characters). NOTE: Valid numbers are [#-32768, #32767] (decimal) or [x0000, xFFFF] (hex).

Your tasks You do not yet know how to take a multi-digit decimal number from user ascii input and convert it to binary, so for this assignment you are going to let the assembler do that part for you: you will use the .FILL pseudo-op to take a literal (decimal or hex, as you wish) and translate it into 16-bit twos complement binary, which will be stored in the indicated memory location; and then you will Load that value from memory into a register. You MUST use the provided hw5 skeleton.asm template to set this up: it ensures that the number to be converted is always stored in the same location (the memory address specified in your template) so we can test your work; make sure you fully understand the code fragment we provide. At this point, your value will be stored in, say, R1: it is now your job to identify the 1s and 0s from the number and print them out to the console one by one, from left (the leading bit, aka the leftmost bit, aka the most significant bit, aka bit 15) to right (the trailing bit, aka the rightmost bit, aka the least significant bit, aka bit 0). Important things to consider: Recall the difference between a positive number and a negative number in 2s complement binary: if the most significant bit (MSB) is 0, the number is considered positive (or zero); if it is 1, the number is negative. The BRanch instruction has parameters (n, z, p) which tell it to check whether the LMR (Last Modified Register) is negative, zero, or positive (or any combination thereof). Hint: what can you say about the msb of the LMR if the n branch is taken? Review the workings of the NZP condition codes and the BR instruction here. Once you are done inspecting the MSB and printing the corresponding ascii 0 or 1, how would you shift the next bit into its place so you could perform the next iteration? Hint: the answer is in the objectives!

Pseudocode: for (i = 15 downto 0): if (msb is a 1): print a 1 else: print a 0 shift left Note on creating LC-3 control structures See here for tips on creating LC-3 versions of the branch and loop control structures you are familiar with from C. Expected / sample output In this assignment, your output will simply be the contents of R1, printed out as 16 ascii 1s and 0s, grouped into packets of 4, separated by spaces (as always, newline terminated, but with no terminating space!). So if the hard coded value was xABCD, your output will be: 1010 1011 1100 1101

Code template:

.ORIG x3000

;------------ ;Instructions ;------------ LD R6, VALUE_PTR ; R6 <-- Pointer to value to be displayed as binary LDR R1, R6, #0 ; R1 <-- Value to be displayed as binary

;------------------------------ ;INSERT CODE STARTING FROM HERE ;------------------------------

HALT

;------------ ;Data ;------------ VALUE_PTR .FILL xB670 ; The address where value to be displayed is stored .END

.ORIG xB670 ; Remote data VALUE .FILL xABCD ; Number to be displayed as binary. Note: label is redundant .END

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

3. What is ethnocentric bias?

Answered: 1 week ago