a)@0///loads constant 0 to register A
D=A//copies content register A to register D
@SP
A=M
M=D
@SP
M=M+1
b)@1
D=A
@LCL
A=M
D=D+A
@LCL
M=D
@SP
M=M-1
A=M
D=M
@LCL
A=M
M=D
@0
D=A
@LCL
A=M
D=A-D
@LCL
M=D
c)@56
D=A
@ARG
A=M
D=D+A
@ARG
M=D
@SP
M=M-1
A=M
D=M
@ARG
A=M
M=D
@56
D=A
@ARG
A=M
D=A-D
@ARG
M=D
Question 26 Write Hack Assembly Language that will implement the following Hack Virtual Machine commands: Virtual Machine Code a) push constant 0 Assembly Language Code [5 marks] b) pop local 1 6 mar...
Question 21 Implement the following code fragments in Hack Virtual Machine code, the variables a, b and c are in the local segment at offsets 4, 5 and 6 respectively. Jack Code a)-(alb) Virtual Machine Code [4 marks] b) (a(b+c) 5 marks] [5 marks] d) Recursive.factorial(6) 2 marks] e) a # c * b 4 marks] Total for Question 21: 20 marks] Question 21 Implement the following code fragments in Hack Virtual Machine code, the variables a, b and c...
(5 points) Consider the following sequence of virtual machine operations . . .enter subroutine label loop push constant push local 1 add pop local 1 push local 1 push arguement 0 gt if-goto end 1 label end return Which of the following high level programming language constructs do the stack operations represent? Let local 1 contain j and arguement O contain n. A. B. C. D. E. while n<-j: j-j+1 while j<=n : J-1 while j<=n: j*)+1 while j<n: j-1...
Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction in hexadecimal. The opcode for sw 43 (101011). sw St1, -4(St3) Question 4 (10 points) Consider the following MIPS assembly code: addi $s3, $0, 5 addi $s1, S0, 3 addi Ss1, $s1, 2 beq Ss3, Ssl, target addi Ss1, Ss1, 1 target: add Ss3, Ss1, Ssl a. After running the code, what is the value of Ss3? b. If the memory address of the...
Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...
All solutions must have both code and data segments Write a sequence of assembly language instructions to subtract each entry of an array B of five two’s complement 16-bit binary integers from the corresponding entry of an array A of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4,...
Assembly language. You can see the question in blue box. Loop Instruction Problem 4: Write and run a program and answer the questions in the box. .data temp dword? First, build and run the program .code - Trace ECX value mov eax,0 ECX=? mov ecx, 10 ; outer loop counter - EAX =? L1: Second: If we removed mov ecx, temp mov eax, 3 What will happen? mov temp.ecx mov ecx,5 ; inner loop counter - build and run the...
please code using risc-v language and make it as simple as possible Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C code. Assume that n and k are passed in x3 and x4 respectively. Values n and k are initialized to 14 and 14. Assume that result returned in register fl and that double precision numbers are used. After you are done store the result in address: 12(x3). Are you allowed to?...
Need help on Assembly language 1.Solve the following conditions: A. Suppose AL contains 11001011 and CF = 1. Give the new contents of AL after each of the following instructions is executed. Assume the above initial conditions for each part of this question. a. SHL AL,1 b. SHR AL,1 c. ROL AL,2 d. ROR AL,3 e. SAR AL,2 f. RCL AL,1 g. RCR AL,3 B. Suppose EAX contain ABCDH. Show the contents of BX and CX after...
Q 4(b) 6 Marks] Write the code for a single Java class of your own choice that demonstrates the use of the following features in the Java language: Method overloadingg The use of super and this Identify clearly where in your code each of these points is being demonstrated Q 4(c) [6 Marks] Write an abstract Student class in Java which has a name, id_number, year and programme_code as member variables. Add a constructor to your class and a display()...
Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...