Question

In: Computer Science

Translate the following tasks into Hack C-Instructions: 1) Set D to A - 1 2) Set...

Translate the following tasks into Hack C-Instructions:

1) Set D to A - 1

2) Set both A and D to A + 1

3) Set D to 19

4) Set both A and D to A + D

5) Set RAM[5034] to D - 1

6) Set RAM[543] to 171

7) Add 1 to RAM[7], and store result in D

8) Add 3 to RAM[12], and store result in D

Solutions

Expert Solution

Hack C-Instructions has the following syntax dest = comp ; jump     // dest ,= and jump mp are optional

Where: comp = 0 , 1 , ‐1 , D , A , !D , !A , ‐D , ‐A , D+1 , A+1 , D‐1, A‐1 , D+A , D‐A , A‐D , D&A , D|A,    M ,      !M ,       ‐M ,       M+1,           M‐1 ,        D+M, D‐M, M‐D, D&M, D|M

dest = M, D,  A, MD, AM, AD, AMD, or null

jump = JGT , JEQ , JGE , JLT , JNE , JLE , JMP, or null

1) Set D to A - 1

Ans:: D = A-1

2) Set both A and D to A + 1

AD=A+1

3) Set D to 19

@19 //A=19

D=A //D=A=19

4) Set both A and D to A + D

AD=A+D // AD means both A and B

5) Set RAM[5034] to D - 1

@5034 //A=5034

M=D-1 //M=RAM[5034] =D-1 , Note M=RAM[A]

6) Set RAM[543] to 171

@171 // A=171

D=A //D=171

@543 //A=543

M=D // M==RAM[A]=RAM[543]=D, RAM[543]=171

7) Add 1 to RAM[7], and store result in D

@7 //A=7

D=M+1 //D=RAM[A] +1=RAM[7] +1

8) Add 3 to RAM[12], and store result in D @3 // A=3

D=A //D=3

@12 //A=12

D=D+M //D=D + RAM[A]=D+RAM[12] =3 +RAM[12]


Related Solutions

Translate the following C code to MIPS assembly. int a = 1; int b = 2;...
Translate the following C code to MIPS assembly. int a = 1; int b = 2; if (a<b)           a=a+1; b = b + a; printf("The value of b is: %d", b); Translate the following C code to MIPS assembly. int a = 2; int b = 2; if (a<b)           a=a+1; else           a=a-1; b = b + a; printf("The value of b is: %d", b);
1. What would be the reason for implementing priviledged instructions 2. Give the tasks of the...
1. What would be the reason for implementing priviledged instructions 2. Give the tasks of the OS in a MULTIPROGRAMMING ENVIRONMENT. 3. What the permission: r-w_ _ _ x means? 4. What is variable of ppid & tty?
Q1: Translate the following Bytes to Decimal and Hexadecimal a) 00001001 b) 111111111 c) 11101110 d)...
Q1: Translate the following Bytes to Decimal and Hexadecimal a) 00001001 b) 111111111 c) 11101110 d) 01010101
Prove that the set R ={ a+ b√2+c√3+d√6 , a,b,c,d belongs to Q } is a...
Prove that the set R ={ a+ b√2+c√3+d√6 , a,b,c,d belongs to Q } is a field
Instructions 1. Column C. should be TYPE: ASSET, LIABILITY, EQUITY, REVENUE OR EXPENSES 2. COLUMN D...
Instructions 1. Column C. should be TYPE: ASSET, LIABILITY, EQUITY, REVENUE OR EXPENSES 2. COLUMN D OR E SHOULD HAVE A YES OR NO. EXAMPLE CASH IS ON THE BALANCE SHEET. HINT: NONE OF THE ACCOUNTS WILL BE ON BOTH. 4. FILL IN DEBIT OR CREDIT- WHICH IS NORMAL BALANCE OF THE ACCOUNT. (INCREASE SIDE) 5. Fill in which type of account is it? Temporary or permanent. account name type asset, liability, equity, revenue or expense will be on the...
Define the following order on the set Z × Z: (a, b) < (c, d) if...
Define the following order on the set Z × Z: (a, b) < (c, d) if either a < c or a = c and b < d. This is referred to as the dictionary order on Z × Z. (a) Show that there are infinitely many elements (x, y) in Z × Z satisfying the inequalities (0, 0) < (x, y) < (1, 1). (b) Show that Axioms O1–O3 ( Trichotomy, Transitivity, Addition for inequalities) are satisfied for this...
1) Provide a set of payoffs in this format a, b      |    c, d e,...
1) Provide a set of payoffs in this format a, b      |    c, d e, f     |     g, i for a 2x2 game that illustrated the problem of free access to guns. 2) Provide a set of payoffs in this format a, b      |    c, d e, f     |     g, i for a 2x2 version of the Battle of the Sexes. 3. In what sense is the Battle of the Sexes a "social dilemma"?
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a,...
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds the base address of the array A (add comments to your MIPS code). j = 0; for(i=0 ; i<a ; i++) A[i]=i+j++;
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
Part 1: answer (a), (b), (c), and (d). Part 2: answer (a), (b), (c), and (d)....
Part 1: answer (a), (b), (c), and (d). Part 2: answer (a), (b), (c), and (d). Godspeed, and good luck!!! CC11 Cookie Creations Natalie and her friend Curtis Lesperance decide that they can benefit from joining Cookie Creations and Curtis’s coffee shop. In the first part of this problem, they come to you with questions about setting up a corporation for their new business. In the second part of the problem, they want your help in preparing financial information following...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT