Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: Calculating...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 10 Topic 4571 of 4710
Post > Topic >>

Re: Calculating checksums...

by Robert Redelmeier <redelm@[EMAIL PROTECTED] > Mar 15, 2008 at 01:40 PM

Tim Roberts <spamtrap@[EMAIL PROTECTED]
> wrote in part:
> Alex Buell  <spamtrap@[EMAIL PROTECTED]
> wrote:
>>I have a snippet of FASM code:
>>; The last byte (512th) will be the patch_byte for the checksum
>>; patch_byte is calculated and automagically inserted below
>>PREV_CHKSUM = 0
>>repeat $
>>   load CHKSUM byte from %-1
>>   CHKSUM = (PREV_CHKSUM + CHKSUM) mod 0x100
>>   PREV_CHKSUM = CHKSUM
>>end repeat
>>store byte (0x100 - CHKSUM) at ($-1)  ; store the patch_byte
>>
>>How would you suggest I could rewrite this in NASM?
> 
> This is one of the easier algorithms to code in assembly.
> 
>    mov  cx, 511
>    xor  dl,dl
> again:
>    lodsb
>    add  dl,al
>    dec  cx
>    jnz  again
>    neg  al
>    mov  ds:[si],al

Small bug?  Shouldn't those last instructions use 
dl as source, not al?  And isn't the ds: redundant?
I presume DF is correctly cleared [upward].

-- Robert
 




 10 Posts in Topic:
Calculating checksums...
Alex Buell <spamtrap@  2008-03-14 19:33:12 
Re: Calculating checksums...
Tim Roberts <spamtrap  2008-03-15 03:18:56 
Re: Calculating checksums...
Robert Redelmeier <red  2008-03-15 13:40:22 
Re: Calculating checksums...
Tim Roberts <spamtrap  2008-03-16 21:13:23 
Re: Calculating checksums...
Frank Kotler <spamtra  2008-03-15 06:14:00 
Re: Calculating checksums...
Alex Buell <spamtrap@  2008-03-15 08:25:41 
Re: Calculating checksums...
Frank Kotler <spamtra  2008-03-15 20:11:34 
Re: Calculating checksums...
Alex Buell <spamtrap@  2008-03-15 08:20:33 
Re: Calculating checksums...
Mike Gonta <spamtrap@  2008-03-15 04:30:28 
Re: Calculating checksums...
Mike Gonta <spamtrap@  2008-03-15 06:32:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 19:22:44 CDT 2008.