Starting from:

$30

CS220 Lab #5 - Solved

 

 Machine Language Basics
  

Translate the following into Assembly Instructions: 

 

1) Set RAM[0] to 3 

Set RAM[1] to 5 

Set RAM[2] to 1 

Set RAM[3] to -1 
 @3 

D = A @0 

M = D @5 

D = A 

@1 

M = D @2 

M = 1 

@3 

M = -1
2) Set RAM[0] to 2 

Set RAM[1] to 3 

Set RAM[2] = RAM[0] + RAM[1] 
 
3)  Set D to A - 1 
 
4) Set both A and D to A + 1 
 
5) Set D to 19 
 
 

6) Set both A and D to A + D 
 
7) Set RAM[5034] to D - 1 
 
8) Set RAM[543] to 171 
 
9) Increment RAM[7]by 1 and store result in D 
 
  10)    Increment RAM[12]by 3 and store result in D 
 
11) // Convert the following Java code to assembly int i = 5; i++; i+=2; i-=3; 
 
12) // Convert the following Java code to assembly int i = 5; int j = 10; int k = i – j; 
 
 

 

 

Translate the following tasks into Assembly Instructions  
1) sum = 0 
 
2) j = j + 1 
 
3) q = sum + 12 - j 
 
4) // Declare that arr=100 and n =10  

 

int n = 10; 

int[] arr = new int[n]; arr[3] = -1 
 
5) // Assume that j has already been declared 

 arr[j] = 0 
 
6) arr[j] = 17 
 
 

Lab #5 - Machine Language Jumps
 

Translate the following instructions into Assembly Instructions
1) goto 50 
 
2) if D==0 goto 112 
 
3) if D<9 goto 507 
 
4) if RAM[12]>0 goto 50 
 
5) if sum>0 goto END 
 
6) if x[i]<=0 goto NEXT 
 
 

 

Lab #5 - Machine Language Loops
 

 

Translate the following instructions into Assembly Instructions
1)  

int n = 5; 

for (int i=1;i<=n;i++) {} 
 
2)  

int sum = 0; int n = 5; 

for (int i=1;i<=n;i++) {   sum += i; 

}
 
3) 

// Declare an arr at RAM[20] 

// Size (n) of 10 for (int i=0; i<n; i++)    arr[i] = -1; 
 
4) 

// Declare an arr at RAM[20] 

// Size (n) of 5 for (int i=0; i<n; i++)    arr[i] = 100; 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

More products