Article View: pl.comp.lang.asm
Article #1507Re: Longhand Division in Binary
From: Bogdan (bogdro)
Date: Wed, 10 Oct 2007 17:32
Date: Wed, 10 Oct 2007 17:32
41 lines
2279 bytes
2279 bytes
Remek pisze:
> Witam
>
> Pod poniższym linkiem są dwa pliki. Jeden z oryginalną procedurą z Art of
> Assembly Language - Figure 4.4 w dziale Advanced Arithmetic, i drugi z
> moją implementacją tej procedury do składni Masm32. Wyniki działania
> programu są nieprawidłowe. Proszę kogoś znającego składnię HLA o
> porównanie obydwu procedur i wskazanie ewentualnych błędów.
1. Źle przetłumaczone linie
QuotAdrs db 128 dup (0)
RmndrAdrs db 128 dup (0)
Var, jak w Pascalu, oznacza wskaźnik. Ale patrząc na resztę kodu,
chyba nie robi to problemów, o ile wynik bierzesz z QuotAdrs i RmndrAdrs.
2. Nieprzetłumaczone są linie
mov( 0, eax ); // Set the remainder to zero.
mov( eax, Remainder[0] );
mov( eax, Remainder[4] );
mov( eax, Remainder[8] );
mov( eax, Remainder[12]);
Jak uruchomisz procedurę więcej niż jeden raz bez zerowania, to klops.
3. Linia
cmp dword ptr dword ptr Divisor[12], eax
zawiera coś zbędnego, ale to też nie problem.
Jak to nie pomoże, to się pomyśli więcej. Słowo "remainder" w
kontekście dzielenia matematycznego oznacza resztę.
--
Pozdrawiam/Regards - Bogdan (Linux & FreeDOS)
Kurs asemblera x86 (DOS & Linux): http://rudy.mif.pg.gda.pl/~bogdro
Grupy dyskusyjne o asm: pl.comp.lang.asm alt.pl.asm alt.pl.asm.win32
Rozmawiaj bezpiecznie: www.JabberPL.org Surfuj anonimowo: tor.eff.org
Technical Details
Message-ID:
<fej2ar$7u6$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<feggr4$9v0$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: "Bogdan (bogdro)" <bogdan@poczta.gazeta.pl> Newsgroups: pl.comp.lang.asm Subject: Re: Longhand Division in Binary Date: Wed, 10 Oct 2007 19:32:06 +0200 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 41 Message-ID: <fej2ar$7u6$1@inews.gazeta.pl> References: <feggr4$9v0$1@inews.gazeta.pl> NNTP-Posting-Host: echo931.server4you.de Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1192037531 8134 85.25.141.60 (10 Oct 2007 17:32:11 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 10 Oct 2007 17:32:11 +0000 (UTC) X-User: bog.d In-Reply-To: <feggr4$9v0$1@inews.gazeta.pl> User-Agent: Thunderbird 2.0.0.6 (X11/20070728) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit