; original codes provided as following
.ORIG x3000 ; begin at x3000
; input two numbers
IN ; input an integer character (ascii) {TRAP 23}
LD R3, HEXN30 ; subtract x30 to get integer
ADD R0, R0, R3
ADD R1, R0, x0 ; move the first integer to register 1
IN ; input another integer {TRAP 23}
ADD R0, R0, R3 ; convert it to an integer
; add the numbers
ADD R2, R0, R1 ; add the two integers
; print the results
LEA R0, MESG ; load the address of the message string
PUTS ; "PUTS" outputs a string {TRAP 22}
ADD R0, R2, x0 ; move the sum to R0, to be output
LD R3, HEX30 ; add 30 to integer to get integer character
ADD R0, R0, R3
OUT ; display the sum {TRAP 21}
; stop
HALT ; {TRAP 25}
; data
MESG .STRINGZ "The sum of those two numbers is: "
HEXN30 .FILL xFFD0 ; -30 HEX
HEX30 .FILL x0030 ; 30 HEX
.END
solution:
-------------------------------------------------------------------------------------------------------------------------------
; original codes provided as following .ORIG x3000 ; begin at x3000 ; input two numbers...
Part 2 (22 pts) .ORIG x3000 LEA R1, STRZ AND R2, R2, #0 LD R4, CHAR REPEAT LDR R3, R1, #0 BRz FINISH ;Branch to FINISH if the value of R3 is zero ADD R3, R3, R4 BRnp PASS ;Branch to PASS if the value of R3 is positive or negative ADD R2, R2, #1 PASS ADD R1, R1, #1 BR REPEAT ;Branch always to REPEAT FINISH ST R2, COUNT HALT CHAR .FILL xFF91 COUNT .FILL x0000 STRZ .STRINGZ "Hello...
I am writing a code for the LC3 Simulator. This is in assembly, I need assistance with the numbers 5-8. Thank you. ALU OPERATIONS 1. Compute the sum X +Y and place it at location x3102. 2. Compute X AND Y and place it at location x3103. 3. Compute X OR Y and place it at location x3104. 4. Compute NOT(X) and place it at location x3105. 5. Compute NOT(Y) and place it at location x3106. 6. Compute X +3...
LC3 stack (factorial) I need help in writing factorial in Lc3 language by using stack.. ; Begin reserved section: do not change ANYTHING in reserved section! .ORIG x3000 BR Main ; Parameter and result Param .FILL x0004 Result .BLKW 1 ; Constants Stack .FILL x4000 One .FILL #1 MinusOne .FILL #-1 ; End reserved section: do not change ANYTHING in reserved section! ;------------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; int Factorial(int N) ; Returns N! (must be a recursive function) ; Factorial ;__________________...
2. Assume there are two 4-byte numbers stored in addresses begin with DATA and DATA2 (lower byte first): it is required to calculate the sum of the tw numbers. Please draw the flowchart to implement this task (can refer to the cod below) R0.#DATA 1 MAIN: MOV MOV R 1 , #DATA2 MOV R2,#0411 CLR C LOOP: MOV A, @Ro ADDC A. @R1 MoV @RO, A INC RO INC RI DJNZ R2. LOOP JC OTHER RET
2. Assume there are...
Write a machine language program to input two one-digit numbers ranging from 0 to 4 (using the character input instruction), add them, and then output the single digit sum (using the character output instruction). Execute your program in the PEP/8 simulator. Example Input: 43 (this is the numbers 4 and 3. Remember, this is two ASCII characters when inputted into your program) Output: 7 (ASCII character 55dec)
Write a program that reads in two hexadecimal numbers from a file, hex.dat, and prints out the sum of the two numbers in hexadecimal. (As noted in class, first do this without using a file and by reading using the cin > > command) From Wikipedia: "In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0-9 to...
21 Write a program that asks the user to input the length and breadth of a soccer field, and then computes and returns the number of square meters of grass required to cover the field The formula for the area is the product of length and breadth (5) 22 The following program uses the break statement to terminate an infinite while loop to print 5 numbers Rewrite the program to use a while loop to display numbers from 1 to...
LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to a function and returning values. Everything is stored on the runtime stack so that space is used only when the function is executing. As a result the actual address of arguments and locals may change from call to call. However, the layout of the stack frame (activation record) is constant. Thus, the offests from the frame pointer (FP) to the parameters/locals are constant. All...
/***************************************************
Name:
Date:
Homework #7
Program name: HexUtilitySOLUTION
Program description: Accepts hexadecimal numbers as input.
Valid input examples: F00D, 000a, 1010, FFFF, Goodbye, BYE
Enter BYE (case insensitive) to exit the program.
****************************************************/
import java.util.Scanner;
public class HexUtilitySOLUTION {
public static void main(String[] args) {
// Maximum length of input string
final byte INPUT_LENGTH = 4;
String userInput = ""; // Initialize to null string
Scanner input = new Scanner(System.in);
// Process the inputs until BYE is entered
do {...
PROBLEM STATEMENT The mini-calculator will use a small ALU to perform arithmetic operations on two 4-bit values which are set using switches. The ALU operations described below are implemented with an Adder/Subtractor component. A pushbutton input allows the current arithmetic result to be saved. An upgraded mini-calculator allows the saved value to be used in place of B as one of the operands. The small ALU that you will design will use the 4-bit adder myadder4 to do several possible...