No your code is still wrong. Below is a piece of code that shows how to store registers in the stack. (It is however far from optimized) In general if you’re out of registers, use the stack. If registers are used in other places in your code and need to persist, use the stack to store them then reset them when you’re done.
calculation:
mov ebx, 0
mov ecx, 7
subtract:
; init
mov eax, 0
mov edx, 0
; al = bit i of x
mov al, X
and al, 1h
; dl = bit i of y
mov dl, Y
and dl, 1h
; save data for later (technique 1 the stack)
push eax
push edx
; bit i of difference = x xor y xor b
xor al, dl
xor al, bl
or diff, al ; or instead of mov
; restore data (technique 1 the stack)
pop edx
pop eax
; b = ((not x) and y) or ((not x) and b) or (y and b)
not al
mov dh, al ; copy not al in dh (technique 2)
and al, dl ; ((not x) and y)
and dh, bl ; ((not x) and b)
and dl, bl ; (y and b)
or al, dh ; ((not x) and y) or ((not x) and b)
or al, dl ; ((not x) and y) or ((not x) and b) or (y and b)
mov bl, al
ror diff, 1
ror X, 1
ror Y, 1
loop subtract
ror diff, 1