// array[N] at address K // sum the values of array // store sum into R0 // N in R5 // K…
- User
// array[N] at address K // sum the values of array // store sum into R0 // N in R5 // K in R6
// if sum even, R2 = 1 // if sum odd, R2 = 0///TODO
// The value of N is provided in R5 and the value of K is in R6. // There are N values stored in an array starting at address K. // Sum these values and store the result in memory location 0. // The value of N is provided in R5 and the value of K is in R6.
// N == @R5 // the number of values in the array // K = @R6 // starting address // @R0 == 0
// This is correct @R6 D=M @K M=D
// Start of loop (LOOP)
// If R7 (N) is 0, jump to END @R7 D=M @END D;JEQ
// Add current value to sum @R0 D=M A=A+D D=M @R0 M=D
// Decrement N @R7 M=M-1
// Increment K @R6 M=M+1
// Jump to loop start @LOOP 0;JMP
(END)
// Check if sum is even or odd @R0 D=M @2 D=D%A @R2 M=D
please fix this implementation. follow the instructions. hack assembley
- Assistant