This code need a bit more refinement, with a bit more work can deal with big numbers.

`;253/7, 253/-7 ;prime numbers`

mov rdi,8000000000000000h ;sign mask

mov rax,117 ;0 ;dividend

mov rbx,-13 ;0 ;divisor

xor rsi,rsi ;quotient

;remainder will be rax

test rbx,rdi ;sign mask, if left most digit is 1 means negative number, if 0 means positive number

jz @F

neg rbx ;two complement

@@:

.if rax < rbx ;2/5, 0/1 ;quotient = 0, remainder = dividend

jmp @F

.endif

.if rbx == 0 ;N/0 ;handle exception

xor eax,eax

div rsi ;forced exception, division by 0

.endif

;--------------------

bsr rcx,rax ;counting rotations

inc rcx

bsr rdx,rbx

inc rdx

sub rcx,rdx ;rcx= final shift, magnitude 2/2 = 0, 3/2 = 0

shl rbx,cl ;align numbers

.repeat

shl rsi,1

.if rax >= rbx

sub rax,rbx ;rax turns into remainder

or rsi,1

.endif

shr rbx,1

dec rcx

.until rcx == -1

@@:

;RESULT

;quotient = 36 ;rsi

;remainder = 1 ;rax

;36*7+1=253