mov ecx,1024 ;divisor
mov eax,N ;your 20 bit N value
xor edx,edx ;clear edx to give EDX:EAX
div ecx ;divide EDX:EAX by ECX, Quotiet in EAX, remainder in EDX
add edx, 16384 ;Result for 1st equation
add eax, 17408 ;Result for 2nd equation
Do you need a DEC2HEX routine or do you assume that exists?
M_DIV: ; Z / X -> Y; remainder -> Z
movlw REG_Y ; passing one value here
call M_CLR ; clearing that resistor
movlw PRECISION*8 ;How it works?
movwf REG_ROT_COUNTER ; passing the multiplied precision value
M_DIV_rot_loop:
btfsc REG_X+PRECISION-1,7; How it works?
goto M_DIV_loop
movlw REG_X
bcf STATUS,C
call M_ROL
decf REG_ROT_COUNTER,f
btfss STATUS,Z
goto M_DIV_rot_loop
bsf STATUS,Z
return