2

I am working on a project to calculate gcd of two 32bit number in 16bit arithmetic assembly. So, how can I split a string containing a 32bit number into two 16bit register?

For example: "1234567891" -> dx=0100 1001 1001 0110 & ax=0000 0010 1101 0011

Amadan
  • 191,408
  • 23
  • 240
  • 301
msk
  • 63
  • 8

1 Answers1

1

You'll need to look at using something called arbitrary precision. Its quite a common process for making calculations on numbers that are larger than a processor may be able to handle.

Have a look at this previous stackoverflow question as it has a good answer to explain how this may be achieved.

Be aware that if you multiply two 32 bit numbers then you may need a 64 bit number to store the result!

Community
  • 1
  • 1
ChrisBD
  • 9,104
  • 3
  • 22
  • 35
  • yes you are trust , i know that you said.i lookup many site as wikipedia , stack_over_flow etc.but i didnt find my expected answer .in other words there is no answer or source code about it :D – msk Jan 12 '12 at 11:19
  • recently i done a project in c++, like this-handle unlimited digits-but in assembly i cant do this.in other words i know what to do, but at first only i dont know how convert sequence of ascii character-at most contained 10digit- to a number and more important split it into two 16bit register like ax:dx.if its possible there are no problem to do other section of my project.i write a 16bit version of gcd finder that it works properly as shown : – msk Jan 12 '12 at 11:26
  • ` .model flat .stack 1024 .data x dw 2620 y dw 3600 .code .startup push x push y call gcd .exit gcd proc near push bp mov bp,sp mov bx,[bp+4] mov cx,[bp+6] cmp bx,0 je retern mov ax,cx xor dx,dx div bx push bx push dx call gcd retern: mov dx,cx pop bp ret 2 gcd endp end ` – msk Jan 12 '12 at 11:27