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 2 of 10 Topic 4571 of 4729
Post > Topic >>

Re: Calculating checksums...

by Tim Roberts <spamtrap@[EMAIL PROTECTED] > Mar 15, 2008 at 03:18 AM

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
-- 
Tim Roberts, timr@[EMAIL PROTECTED]
 & Boekelheide, Inc.
 




 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 Fri Jul 25 14:44:17 CDT 2008.