Re: The prodigal son returns...more easy Homework Help...
- From: o/annabee <hu@localhost>
- Date: Mon, 26 Nov 2007 08:18:12 +0100
On Tue, 20 Nov 2007 21:40:34 +0100, Frank Kotler <fbkotler@xxxxxxxxxxx> wrote:
kuroikaze@xxxxxxxxx wrote:; Find Prime Numbers and output file
To prove that flattery will get you everywhere, and that you *can* sometimes find the bug by looking at the source, I offer this preliminary observation...
(only really just started looking at this. *if* my ambition holds up, I'll have more to say...)
...pNumsUp WORD pNumsUpMax DUP (?)
pNumsDown WORD pNumsDwnMax DUP (?)
You then go on to *use* these as DWORD arrays!!! (mov [ebx], eax and its opposite. Looking at your output, you're obviously "running off the end" of the "lower" array, and printing one number from the "higher" array. Changing these to DWORD would fix that symptom, but may not account for "all those zeros". Start with that...
...; pop dx
They're currently commented out, but in 32-bit code, you want to push and pop full 32-bit registers.
Just wanted to add that in general it is ok
to push and pop 16 bit values as long as the stack remain aligned
afterwards
push D$eax ;push 32 bit
pop bx ;two pops to 16 bits registers
pop cx
is ok for instance. and variants are ok.
the point is that ESP is aligned _afterwards_.
No matter the method used to manipulate it.
Doing 16-bit registers will give you a badly aligned stack, or worse. There may be other places where you want to change from 16-bit registers to 32-bit registers, as well. It "sounds logical" that 16-bit calculations would be faster and "easier for the CPU". Not so (usually). The CPU works best on "native word size" - 32 bits, in this case.
; cmp dh, 1
8-bit registers are fine...
Fix the size of those arrays, and see if it helps.
Later,
Frank
P.S. I agree with the folks who say you should learn to use a debugger (and I agree with you that the results are somewhat cryptic until you figure out what you're looking at). You mentioned Windbg... Ollydbg is another "popular" one (maybe "better"?). But Masm outputs symbolic debug information in a format for Codeview - if you've got that, or can "obtain" it, that might be a good one to look at. too.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
.
- References:
- The prodigal son returns...more easy Homework Help...
- From: kuroikaze
- Re: The prodigal son returns...more easy Homework Help...
- From: kuroikaze
- Re: The prodigal son returns...more easy Homework Help...
- From: Frank Kotler
- The prodigal son returns...more easy Homework Help...
- Prev by Date: Re: how can i know the true religion?
- Next by Date: Re: how can i know the true religion?
- Previous by thread: Re: The prodigal son returns...more easy Homework Help...
- Next by thread: Re: The prodigal son returns...more easy Homework Help...
- Index(es):
Relevant Pages
|