# Assembly question

Discussion in 'Assembly Language Programming (ALP) Forum' started by Niro7777777@, Feb 2, 2010.

1. ### Niro7777777@New Member

Joined:
Feb 2, 2010
Messages:
1
Likes Received:
0
Trophy Points:
0
I have two different lists

qlst1 dq 80000, 40000, 123123, 123123
dlst1 dd 533, 2314, 123, 231

alst1 dd 4 (?) DUP

Now I want to divide the qlst by dlst and then save in the alst which is alst1
How do I do it. qlst1 is a quad so that I cannot put in a register directly.

mov eax, dlst
lea ebx, qlst

mov eax, dword ptr[ebx]+4
mov alst, eax

I am lost from here, please help

2. ### xpi0t0sMentor

Joined:
Aug 6, 2004
Messages:
3,012
Likes Received:
203
Trophy Points:
0
Occupation:
Senior Support Engineer
Location:
England
Do you remember doing long division at school? For example 56473/27 might be done as:
Code:
```    __2091_
27 ) 56473
54
--
247
243
---
43
27
--
16

56473/27=2091 r 16
```
So one way is to code up this algorithm. Another way is to shift and subtract, e.g.
56473/27

part 1:
27>56473? no: shift left and repeat (should that be > or >=?)
270>56473? no: shift left and repeat
2700
27000
270000>56473? yes: shift right

part 2:
27000>56473? no: subtract

56473
27000-
=====
29473

27000>29473? no: subtract (leaves 2473)
27000>2473? yes: shift right
2700>473? yes: shift right
270>2473? no: subtract
270>2203? no: subtract
270>1933? no: subtract
270>1663? no: subtract
270>1393? no: subtract
270>1123? no: subtract
270>853? no: subtract
270>583? no: subtract
270>313? no: subtract
270>43? yes: shift right
27>43? no: subtract
27>16? yes: can't shift right any more so this ends the loop.

This doesn't show where you get the answer (2091) from, but maybe you can figure that bit out?