List the SHORTEST POSSIBLE CODE (counting number of instructions) for making x, y, and z, defined as follows, get the value 1.
for an 80*86 machine
x: dw 0xff00
y: resb 1
z: resw 1
edit:
I think the answer should be somethink like that:
MOV DWORD [x+1], 0x01010001 ;
;check:
mov eax , 0
mov al , byte[y]
print_d eax ; print 0
mov eax , 0
mov ax , word[x]
print_d eax ; print 256
mov eax , 0
mov ax , word[z]
print_d eax ; print 257
but. it is not good…sholud print 1
Here’s the memory where your
x,yandzare, listed as bytes (from lower addresses (x) to higher (z)):where
xxis the least significant byte ofx(0),XXis the most significant byte ofx(0xFF) and likewise foryandz.If I understand it correctly,
yandzaren’t initialized (res*hints NASM syntax for memory reservation keywords).So you want to transform this:
into this:
Right?
MOV DWORD [x+1], 0x01010001will transform it into:So, it’s not correct. And you need more than 1 instruction to change 5 bytes because 32-bit instructions write at most 4 bytes at a time.
I’d say the shortest in terms of the number of instructions is 2
MOVs(NASM syntax):