To start, the 32-bit dividend is in N+2 (byte 2), N+3 (byte 1, or hi byte), N+4 (byte 4, or lo byte), & N+5 (byte 3).
The 16-bit divisor is in N+0 and N+1 (lo byte first, as is usual for the 6502). "N" is the beginning address of a small scratchpad area of RAM.
At the end, the 16-bit quotient is in N+4 & N+5, and 16-bit remainder is in N+2 & N+3 both with low byte first, as usual for 6502, like the divisor shown above. In other words, the remainder and quotient end up in the same memory bytes that originally held the dividend.
ROL N+4
ROL N+5
DEX
BEQ end
ROL N+2
ROL N+3
LDA #$00
STA carry
ROL carry
SEC
LDA N+2
SBC N
STA N+6
LDA N+3
SBC N+1
TAY
LDA carry
SBC #$00
BCC loop
LDA N+6
STA N+2
STY N+3
BCS loop
Overflow: