flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
decard 08 Nov 2004, 19:17
quick dirty solution, but you should be able to modify it that it would fit your needs.
Code: macro generate_crc starting_lbl, ending_lbl { __ptr = starting_lbl __times = (ending_lbl-starting_lbl)/4 __sum = 0 repeat __times load __tmp dword from __ptr __sum = __sum + __tmp __ptr = __ptr + 4 end repeat dd __sum and 0xffffffff } it will store dword value that would be a sum of all dwords in the output code, between two given labels. Example: Code: begin: dd 11 dd 2 dd 2 finish: db "CRC:" generate_crc begin,finish |
|||
![]() |
|
Matrix 08 Nov 2004, 19:32
Thank you Decard
![]() |
|||
![]() |
|
Matrix 08 Nov 2004, 19:42
Here is what i did with it, not much modification was needed
![]() now works with any block size well exacly this is not a full crc32, but it should be enough for me now Code: macro generate_crc starting_lbl, ending_lbl { __ptr = starting_lbl __lenght = ending_lbl-starting_lbl __times = (__lenght)shr 2 __timesleft = (__lenght)-(((__lenght)shr 2)shl 2) ; remaining 3 - 0 __timesleft2 =__timesleft shr 1 ; word __timesleft3 =__timesleft - (__timesleft2 shl 1) ; last byte __sum = 0 repeat __times load __tmp dword from __ptr __sum = __sum xor __tmp __ptr = __ptr + 4 end repeat if __timesleft2>0 ; word load __tmp word from __ptr __sum = __sum xor (__tmp and $ffff) __ptr = __ptr + 2 end if if __timesleft3>0 ; last byte load __tmp byte from __ptr __sum = __sum xor (__tmp and $ff) __ptr = __ptr + 1 end if dd __sum and 0xffffffff } ;it will store dword value that would be a sum of all dwords in the output code, between two given labels. Example: ;Code: dd $ABCD begin: dd 10101010101010101010101010101010b dd 11111111111111111111111111111111b dd 11111111111111111111111111111111b dd 10101010101010101010111010101010b db 1b,0 ; dw 1b ; dw 0 ; dw 100000001b finish: db "CRC:" generate_crc begin,finish |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.