I am having some trouble with the following question over ARMv8 assembly. The ma
ID: 3786282 • Letter: I
Question
I am having some trouble with the following question over ARMv8 assembly. The main area I am not understanding are the last two lines. Thank you.
What value is left in X0 after the following code is run (Remember ARMv8 is big endian)?
ORR X1, XZR, 0x1234
ORR X2, XZR, 0x4
ADD X10, XZR, XZR
ADD X0, XZR, XZR
STUR X1, [X2, 0]
LDURB X0, [X2, 6]
Note, LDURB operates on bytes instead of words.
What value is left in X0 after the following code is run (Remember ARMv8 is big endian)?
ORR X1, XZR, 0x1234
ORR X2, XZR, 0x4
ADD X10, XZR, XZR
ADD X0, XZR, XZR
STUR X1, [X2, 0]
LDURB X0, [X2, 6]
Note, LDURB operates on bytes instead of words.
Explanation / Answer
XZR register is a zero register
ORR X1, XZR, 0x1234 // X1 gets XZR OR 0x1234
ORR X2, XZR, 0x4 //X2 gets XZR OR 0x4
ADD X10, XZR, XZR // X10 general purpose register get XZR + XZR
ADD X0, XZR, XZR
STUR X1, [X2, 0] // stores 8bit Bt value [BASE + SIMM9] i.e., [X2+0] gets the value of X1 which has OR value from 1st instruction
LDURB X0, [X2, 6] // loads [base+ simm9] value to X0 i.e., X0 gets value of [X2+6] value
i.e., taking XZR value as 0 we get X0 value as 0XA
Syntax
LDURB Wt, [Xn|SP{, #simm}]
Load Register Byte (unscaled) calculates an address from a base register and an immediate offset, loads a byte from memory, zero-extends it, and writes it to a register.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.