PROGRAM:
.ORIG x3000 ;
Program strat at address x3000
LD R0,Data1 ; Load the
value of data1 into R0
AND R1,R1,#0 ; Clear
contents of R1
ADD R1,R1,#1 ; Value to
be compared to Data1
AND R2,R2,#0 ; Clear
contents of R2, Counter variable
AND R3,R3,#0 ; Clear
contents of R3, Result variable
loop
ADD R2,R2,#1 ;
Increment counter by 1
AND R4,R4,#0 ; Clear
contents of R4
AND R4,R0,R1 ; R4=1, If
LSB of R0 is 1
BRP yes
no ADD R1,R1,R1 ; Shift
the contents of R1 to left
BR next
yes ADD R3,R3,#1 ;
Increment result variable by 1
BR no
next AND R4,R4,#0 ;
Clear contents of R4
ADD R4,R2,#-16 ; Loop
terminating condition
BRN loop
end_loop
LEA R0,prompt ; Load
the address of the string
PUTS
; Print the string
ADD R4,R3,#-9 ; Check
whether the result is >9
BRp next1 ; if yes jump
to label next1
LD R1,ASCII ; else,
Load the value of ASCII into R1
ADD R0,R3,R1 ; Move
result to R0
ST R0,result ; Store
the result
BR exit
; branch to label exit
next1 LD R1,char_val ;
Load the value of ASCII into R1
ADD R0,R4,R1 ; Move
result to R0
ST R0,result ; Store
the result
exit LEA R0,result ;
Load the address of the result
PUTS
; print the result
HALT
Data1 .FILL x0002 ; data1
value
prompt .STRINGZ "Number of non-zero bits: x"
ASCII .FILL x30
char_val .FILL #65
result .BLKW #1
.END
Please refer to the following screenshot of the program for indentation of the code:
OUTPUTS:
When Data1 = x0002
When Data1 = xDEED
Question: WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT ... WRITE A PROGRAM IN LC-3...
1) Write an LC-3 assembly language routine that displays exactly 100 Zs on the screen. 2) Write an LC-3 assembly language routine that determines if a number stored in R2 is odd. Write an LC-3 assembly language routine to shift a binary number one position to the left. For example: 0011 should become 0110.
In this problem, you will write an assembly program (LC-3 assembly language) to process a string starting at memory location x5000, and is terminated by a ‘\0’ character (ASCII value = 0). For a given string beginning atmemory location x5000, convert all the upper-case English letters (A-Z) to lower-case, and all the lower case (a-z) to upper case. For example, if the string is “iLOVEComputerScience252”, the string after the processing should be: “IlovecOMPUTERsCIENCE252”. Store the string after the processing to...
In this problem, you will write an assembly program (LC-3 assembly language) to process a string starting at memory location x5000, and is terminated by a ‘\0’ character (ASCII value = 0). For a given string beginning at memory location x5000, convert all the upper-case English letters (A-Z) to lower-case, and all the lower case (a-z) to upper case. For example, if the string is “iLOVEComputerScience252”, the string after the processing should be: “IlovecOMPUTERsCIENCE252”. Store the string after the processing...
Write an assembly language program to do the following, and run it and test it on the lab simulator: Read in integers until a zero is read in. Keep a total of both the quantity and the sum of the negative integers and the positive integers. Once a zero is read in (signifying the end of the input) then: • If there were more positive than negative integers, or an equal number, print out a 0 and the sum of...
it's in C programming language 3. Write a program to find out if the first two bits of an input hex number is 11and will print "the first two bits are ones" 4- Write a program that will perform the following: Check the first two numbers of an input data if they are 11 and will print "open door 1" if so, otherwise Check the last two bits of that number if they are 11 and print" Open door 2...
Write MARIE assembly language programs that do the following: I. Write a program that inputs three integers, a, b, and c, in that order. It computes the following ia-bi-fc+ c The result should be written to output 2. Write a program that inputs integers, s. y, and z. It outputs the difference of the langest and first element entered. You may assume x. y, and z all have different values. So if 8, 12, and 9 are input, the output...
Write an assembly language program that reads in a number, n, and outputs, Fibonacci number, F_n. Test your program on input 13. Turn in a listing of your program, and the results of this test run. (Your answer should be 233.)
Programming: Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in the lab notes and the above practice. The program will do the following: Prompt the user to enter a string. The program will call the procedure vowelp to check if a character entered in the string is a vowel or not. Count how many vowels and how many non-vowels are in the string. Print out the calculated results with appropriate message. Hint: A loop is...
in c programming language . 10.14 (Reversing the Order of an Integer's Bits) Write a program that reverses the order of the bite! in an unsigned int value. The program should input the value from the user and call function re verseBits to print the bits in reverse order. Print the value in bits both before and after the bits are reversed to confirm that the bits are reversed properly.
NEED HELP WITH THIS . Write a MARIE assembly language program that would simulate calling and executing the following C function, as shown below: z = someFunction(a, b); where z, a and b are main( ) program variables, and the values stored in a and b are input by the user. The value stored in z will be output. Did your program execute correctly? This is the code for the function: int someFunction(int x, int y) { return 3 *...