Write LEG if assembly language programs for the following c

Write LEG if assembly language programs for the following c program fragments please make sure to add any necessary comments. If (a! = b) {p[10] = p[10]; {else {p[10]=p[10]-1;}

Solution

STUR X9,a ;(store a in register X9)

STUR X20,b ;(store a in register X20)

STUR X21,p ;(load reference of p in register X21)

SUB X22,X9,X20 ;(perform X9-X20 and store in X22)

LDUR X23, [X21,#80] ;(index 10 required 80 offset value, here p[10] will load in X23)

CBNZ X22,l1 ;(if X22 will not equal to 0 then control will jump to l1, means if a != b)

SUBI X23,X23,#1 ;(else 1 will be added to X23 and vaue will stored in X23)

l1: ADDI X23,X23,#1 ;(1 will be added in X23 and stored in X23)

 Write LEG if assembly language programs for the following c program fragments please make sure to add any necessary comments. If (a! = b) {p[10] = p[10]; {else

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site