Rewrote completely from scratch for fasm under Windows, but using 16-bit registers in computations. This requires some care, because during squaring, when calculating the dividend, the output exceeds 16 bits, the result of the exponentiation is placed in dx:ax . At each stage for control, I made a debugging output (now commented out).
; x= ((d^2 - a)^2)/(d^2 + b))-20, при a=10, b=4, d=-23 format PE console include 'win32ax.inc' entry start section '.data' data readable writeable A dw 10 B dw 4 D dw -23 _fmt db '%d',13,10,0 D2 dw ? divider dw ? section '.code' code readable executable start: ; D2 = D * D mov ax, [D] imul ax mov [D2], ax ; movsx eax, ax ; cinvoke printf, _fmt, eax ; mov ax, [D2] ; (D^2 + B) ; В данном случае удобнее считать сначала делитель add ax, [B] mov [divider], ax ; movsx eax, ax ; cinvoke printf, _fmt, eax ; (D^2 - A)^2 mov ax, [D2] sub ax, [A] imul ax ; результат в dx:ax ; push dx ; push ax ; shl edx, 16 ; mov dx, ax ; cinvoke printf, _fmt, edx ; pop ax ; pop dx idiv [divider] ; делимое в dx:ax, результат в ax ; push ax ; movsx eax, ax ; cinvoke printf, _fmt, eax ; pop ax sub ax, 20 movsx eax, ax cinvoke printf, _fmt, eax invoke getch invoke ExitProcess section '.idata' import data readable library kernel, 'kernel32.dll', \ msvcrt,'msvcrt.dll' import kernel,\ ExitProcess, 'ExitProcess' import msvcrt,\ printf,'printf',\ getch,'_getch'
The result is 485. For verification, here is the python code:
a=10 b=4 d=-23 x=((d**2-a)**2)//(d**2+b)-20 print(x)
Conclusion: 485
int 21h! And you tried to pass under a debugger? And then debugging assembler "in the head" is not an easy task. - VladD