|
Prev: stricmp
Next: Killing Explorer
From: Herbert Kleebauer on 12 Mar 2005 11:07 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; md5.mac ;; ;; calculate md5 hash for stdin (see RFC 1321) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; UseIdatSection=0 ; 0 if no idat section is used UseUdatSection=0 ; 0 if no udat section is used ;#==================================================================# ;# Start of Headers # ;#==================================================================# ; +--------------------------------------------+ ; | Start of DOS Header | ; +--------------------------------------------+ ; DOS .EXE header dc.b 'MZ' ; Magic number dc.w dosfilesize\512 ; Bytes on last page of file (0->512) dc.w (dosfilesize-1)/512+1 ; Pages in file (Page=512 byte) dc.w 0 ; Relocations (nr of entries) dc.w doshead_end/16 ; Size of header size in paragraphs (16 byte) dc.w 0 ; Minimum extra paragraphs needed dc.w $ffff ; Maximum extra paragraphs needed dc.w 0 ; Initial (relative) SS value (ss=load_adr+nr) dc.w dosstack ; Initial SP value dc.w 0 ; Checksum dc.w dosmain ; Initial IP value dc.w 0 ; Initial (relative) CS value (cs=load_adr+nr) dc.w reloc ; File address of relocation table dc.w 0 ; Overlay number dc.w 0,0,0,0 ; Reserved words dc.w 0 ; OEM identifier (for e_oeminfo) dc.w 0 ; OEM information; e_oemid specific dc.l 0,0,0,0,0 ; Reserved words dc.l WinHeader ; File address of new exe header reloc: doshead_end: @=$0 dosmain:move.w s6,-(sp) move.w (sp)+,s0 move.w #_text,r1 move.b #$09,m0 trap #$21 move.w #$4c01,r0 trap #$21 _text: dc.b 'Nice to meet somebody who is still using DOS,',13,10 dc.b 'but his program requires Win32.',13,10,'$' even 16 dosstack=@+256 ; 256 Byte stack dosfilesize=@+256 ; +--------------------------------------------+ ; | End of DOS Header | ; +--------------------------------------------+ ; +--------------------------------------------+ ; | Start of Windows Header | ; +--------------------------------------------+ ImageBase== $00400000 SectionAlignment== 4096 FileAlignment== 512 WinHeader=@@ @=ImageBase ; see WINNT.H for information dc.b 'PE',0,0 ; magic word ; _IMAGE_FILE_HEADER: dc.w $014c ; Machine ($014c=Intel x86 processor) dc.w NumberOfSections ; NumberOfSections dc.l $36a57950 ; TimeDateStamp (seconds since 31.12.69 16:00) dc.l 0 ; PointerToSymbolTable dc.l 0 ; NumberOfSymbols dc.w SizeOfOptionalHeader ; SizeOfOptionalHeader dc.w $010f ; Charcteristics ; 0x0001 Relocation info stripped from file. ; 0x0002 File is executable (i.e. no unresolved externel references). ; 0x0004 Line nunbers stripped from file. ; 0x0008 Local symbols stripped from file. ; 0x0010 Agressively trim working set ; 0x0080 Bytes of machine word are reversed. ; 0x0100 32 bit word machine. ; 0x0200 Debugging info stripped from file in .DBG file ; 0x0400 If Image is on removable media, copy and run from the swap file. ; 0x0800 If Image is on Net, copy and run from the swap file. ; 0x1000 System File. ; 0x2000 File is a DLL. ; 0x4000 File should only be run on a UP machine ; 0x8000 Bytes of machine word are reversed. @a=@ ; _IMAGE_OPTIONAL_HEADER dc.w $010b ; Magic dc.b 5 ; MajorLinkerVersion dc.b 12 ; MinorLinkerVersion dc.l SizeOfCode ; SizeOfCode dc.l SizeOfInitializedData ; SizeOfInitializedData dc.l SizeOfUninitializedData ; SizeOfUninitializedData dc.l winmain-ImageBase ; AddressOfEntryPoint dc.l BaseOfCode ; BaseOfCode dc.l BaseOfData ; BaseOfData dc.l ImageBase ; ImageBase dc.l SectionAlignment ; SectionAlignment dc.l FileAlignment ; FileAlignment dc.w 4 ; MajorOperatingSystemVersion dc.w 0 ; MinorOperatingSystemVersion dc.w 0 ; MajorImageVersion dc.w 0 ; MinorImageVersion dc.w 4 ; MajorSubsystemVersion dc.w 0 ; MinorSubsystemVersion dc.l 0 ; Win32VersionValue dc.l SizeOfImage ; SizeOfImage dc.l SizeOfHeaders ; SizeOfHeaders dc.l 0 ; CheckSum dc.w 3 ; Subsystem ; 0: Unknown subsystem. ; 1: Image doesn't require a subsystem. ; 2: Image runs in the Windows GUI subsystem. ; 3: Image runs in the Windows character subsystem. ; 5: image runs in the OS/2 character subsystem. ; 7: image run in the Posix character subsystem. ; 8: image run in the 8 subsystem. dc.w $0000 ; DllCharacteristics dc.l $00100000 ; SizeOfStackReserve dc.l $00001000 ; SizeOfStackCommit dc.l $00100000 ; SizeOfHeapReserve dc.l $00001000 ; SizeOfHeapCommit dc.l $00000000 ; LoaderFlags dc.l NumberOfRvaAndSize ; NumberOfRvaAndSize (entries ; in the data dir) ; .............................................. ; : Start of Image Data Directory : ; .............................................. ; virtual address, size @b=@ dc.l 0,0 ; Export Directory dc.l imp_start,imp_size ; Import Directory dc.l 0,0 ; Resource Directory dc.l 0,0 ; Exception Directory dc.l 0,0 ; Security Directory dc.l 0,0 ; Base Relocation Table dc.l 0,0 ; Debug Directory dc.l 0,0 ; Description String dc.l 0,0 ; Machine Value (MIPS GP) dc.l 0,0 ; TLS Directory dc.l 0,0 ; Load Configuration Directory dc.l 0,0 ; Bound Import Directory in headers dc.l iat_start,iat_size ; Import Address Table dc.l 0,0 ; 14 dc.l 0,0 ; 15 dc.l 0,0 ; 16 NumberOfRvaAndSize = (@-@b)/8 SizeOfOptionalHeader = @-@a ; .............................................. ; : End of Image Data Directory : ; .............................................. ; .............................................. ; : Start of Image Sections Header : ; .............................................. @a=@ dc.b '.text',0,0,0 ; name dc.l VSizeOf_text ; virtual size dc.l VBaseOf_text ; virtual address dc.l FSizeOf_text ; size of raw data dc.l FBaseOf_text ; pointer to raw data dc.l 0 ; pointer to relocatins dc.l 0 ; pointer to line numbers dc.w 0 ; number of relocations dc.w 0 ; number of line numbers dc.l $e0000020 ; characteristics IF UseIdatSection dc.b '.idat',0,0,0 ; name dc.l VSizeOf_idat ; virtual size dc.l VBaseOf_idat ; virtual address dc.l FSizeOf_idat ; size of raw data dc.l FBaseOf_idat ; pointer to raw data dc.l 0 ; pointer to relocatins dc.l 0 ; pointer to line numbers dc.w 0 ; number of relocations dc.w 0 ; number of line numbers dc.l $e0000040 ; characteristics ENDIF IF UseUdatSection dc.b '.udat',0,0 ; name dc.l VSizeOf_udat ; virtual size dc.l VBaseOf_udat ; virtual address dc.l FSizeOf_udat ; size of raw data dc.l FBaseOf_udat ; pointer to raw data dc.l 0 ; pointer to relocatins dc.l 0 ; pointer to line numbers dc.w 0 ; number of relocations dc.w 0 ; number of line numbers dc.l $e0000080 ; characteristics ENDIF NumberOfSections=(@-@a)/40 ; .............................................. ; : End of Image Sections Header : ; .............................................. ; characteristics ; 0x00000020 // Section contains code. ; 0x00000040 // Section contains initialized data. ; 0x00000080 // Section contains uninitialized data. ; 0x00000200 // Section contains comments or some other type of information. ; 0x00000800 // Section contents will not become part of image. ; 0x00001000 // Section contents comdat. ; 0x01000000 // Section contains extended relocations. ; 0x02000000 // Section can be discarded. ; 0x04000000 // Section is not cachable. ; 0x08000000 // Section is not pageable. ; 0x10000000 // Section is shareable. ; 0x20000000 // Section is executable. ; 0x40000000 // Section is readable. ; 0x80000000 // Section is writeable. ; +--------------------------------------------+ ; | End of Windows Header | ; +--------------------------------------------+ evencom FileAlignment SizeOfHeaders==@@ ;#==================================================================# ;# End of Headers # ;#==================================================================# ;#==================================================================# ;# Start of Sections # ;#==================================================================# ; +--------------------------------------------+ ; | Start of .text Section | ; +--------------------------------------------+ FBaseOf_text==@@ VBaseOf_text==(@-ImageBase+SectionAlignment-1)/SectionAlignment*SectionAlignment BaseOfCode==VBaseOf_text @=ImageBase+VBaseOf_text ; .............................................. ; : Start of Thunk Table : ; .............................................. iat_start=@-ImageBase USER32_thunk: MessageBoxA:: dc.l USER32_MessageBoxA -ImageBase dc.l 0 KERNEL32_thunk: ExitProcess:: dc.l KERNEL32_ExitProcess -ImageBase GetStdHandle:: dc.l KERNEL32_GetStdHandle -ImageBase ReadFile:: dc.l KERNEL32_ReadFile -ImageBase WriteFile:: dc.l KERNEL32_WriteFile -ImageBase dc.l 0 iat_size=@-ImageBase-iat_start ; .............................................. ; : End of Thunk Table : ; .............................................. ; .............................................. ; : Start of Import Directory : ; .............................................. imp_start==@-ImageBase imp: dc.l USER32_import -ImageBase dc.l 0 dc.l 0 dc.l USER32_name -ImageBase dc.l USER32_thunk -ImageBase dc.l KERNEL32_import -ImageBase dc.l 0 dc.l 0 dc.l KERNEL32_name -ImageBase dc.l KERNEL32_thunk -ImageBase dc.l 0 dc.l 0 dc.l 0 dc.l 0 dc.l 0 imp_size==@-imp ; .............................................. ; : End of Import Directory : ; .............................................. USER32_name: dc.b 'USER32.dll',0 even USER32_import: dc.l USER32_MessageBoxA -ImageBase dc.l 0 even USER32_MessageBoxA: dc.w 0 dc.b 'MessageBoxA',0 even KERNEL32_name: dc.b 'KERNEL32.dll',0 even KERNEL32_import: dc.l KERNEL32_ExitProcess -ImageBase dc.l KERNEL32_GetStdHandle -ImageBase dc.l KERNEL32_ReadFile -ImageBase dc.l KERNEL32_WriteFile -ImageBase dc.l 0 even KERNEL32_ExitProcess: dc.w 0 dc.b 'ExitProcess',0 even KERNEL32_GetStdHandle: dc.w 0 dc.b 'GetStdHandle',0 even KERNEL32_ReadFile: dc.w 0 dc.b 'ReadFile',0 even KERNEL32_WriteFile: dc.w 0 dc.b 'WriteFile',0 even ; .............................................. ; : Start of Code : ; .............................................. label_block seg32 winmain:: bclr.w #10,sr ; clear direction flag for auto increment eor.l r4,r4 ; low bit count eor.l r5,r5 ; high bit count _11: move.l #64,r2 ; read 64 bytes move.l #buf,r6 ; pointer to 64 byte buffer _10: bsr.l getc ; read char from stdin move.b r0,(r6)+-{s1} ; store in buffer and increment pointer cmpq.l #-1,r0 ; end of file beq.b _20 ; yes addq.l #1,r4 ; incr total number of read bytes addcq.l #0,r5 dbf.l r2,_10 ; repeat until 64 bytes read bsr.l md5 ; update md5 hash for 64 bytes read br.b _11 ; next 64 byte block _20: dsl.l #3,r5<r4 ; total number of read bits lsl.l #3,r4 move.b #$80,-1.b(r6) ; replace EOF by $80 _31: move.l r6,-(sp) ; save pointer _30: cmp.l #buf+63,r6 bhi.b _32 move.b #0,(r6) ; fill rest of buffer with 0 inc.l r6 br.b _30 _32: move.l (sp)+,r6 cmp.l #buf+56,r6 ; 8 bytes free in buffer? bls.b _40 ; yes bsr.l md5 ; update md5 hash for 64 bytes in buffer move.l #buf,r6 ; need a fresh 64 byte block br.b _31 _40: move.l r4,buf+56 ; insert bit count in last 8 bytes move.l r5,buf+60 bsr.l md5 ; update md5 hash for 64 bytes in buffer move.l #a,r5 ; pointer to hash value move.l #16,r2 ; 16 byte hash _60: move.b (r5),r0 ; next byte of hash lsr.b #4,r0 ; upper nippel bsr.l _70 ; convert to hex and output move.b (r5)+-,r0 ; get byte again and inc pointer and.b #$0f,r0 ; lower nippel bsr.l _70 ; convert to hex and output dbf.l r2,_60 ; all 16 byte done? bsr.l exit _70: add.b #'0',r0 ; convert to ascii cmp.b #'9',r0 ; lower same '9' bls.b _50 ; yes, then ok add.b #'a'-'9'-1,r0 ; no, convert to a-f _50: bsr.l putc rts.l md5: ; this is a 1:1 implementation of the code in RFC 1321 ; so no documentation is given here move.l r5,-(sp) ; don't modify r4 and r5 move.l a,r0 move.l r0,aa move.l b,r0 move.l r0,bb move.l c,r0 move.l r0,cc move.l d,r0 move.l r0,dd move.l #a,r5 eor.l r3,r3 _10: cmp.b #15,r3 bhi.b _20 move.l 4.b(r5),r0 move.l r0,r1 and.l 8.b(r5),r1 not.l r0 and.l 12.b(r5),r0 or.l r1,r0 br.b _50 _20: cmp.b #31,r3 bhi.b _30 move.l 12.b(r5),r0 move.l r0,r1 and.l 4.b(r5),r1 not.l r0 and.l 8.b(r5),r0 or.l r1,r0 br.b _50 _30: cmp.b #47,r3 bhi.b _40 move.l 4.b(r5),r0 eor.l 8.b(r5),r0 eor.l 12.b(r5),r0 br.b _50 _40: move.l 12.b(r5),r0 not.l r0 or.l 4.b(r5),r0 eor.l 8.b(r5),r0 _50: add.l (r5),r0 movu.bl index(r3),r6 add.l buf(r6*4),r0 add.l sin(r3*4),r0 move.b shift(r3),r2 rol.l r2,r0 add.l 4.b(r5),r0 move.l r0,(r5) move.l r0,16.b(r5) subq.l #4,r5 cmp.l #b0,r5 bhs.b _60 addq.l #16,r5 _60: inc.b r3 cmp.b #64,r3 blo.l _10 move.l aa,r0 add.l r0,a add.l r0,a0 move.l bb,r0 add.l r0,b add.l r0,b0 move.l cc,r0 add.l r0,c add.l r0,c0 move.l dd,r0 add.l r0,d add.l r0,d0 move.l (sp)+,r5 rts.l b0: dc.b $89,$ab,$cd,$ef c0: dc.b $fe,$dc,$ba,$98 d0: dc.b $76,$54,$32,$10 a: dc.b $01,$23,$45,$67 b: dc.b $89,$ab,$cd,$ef c: dc.b $fe,$dc,$ba,$98 d: dc.b $76,$54,$32,$10 a0: dc.b $01,$23,$45,$67 index: dc.b 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 dc.b 1, 6,11, 0, 5,10,15, 4, 9,14, 3, 8,13, 2, 7,12 dc.b 5, 8,11,14, 1, 4, 7,10,13, 0, 3, 6, 9,12,15, 2 dc.b 0, 7,14, 5,12, 3,10, 1, 8,15, 6,13, 4,11, 2, 9 shift: dc.b 7,12,17,22, 7,12,17,22, 7,12,17,22, 7,12,17,22 dc.b 5, 9,14,20, 5, 9,14,20, 5, 9,14,20, 5, 9,14,20 dc.b 4,11,16,23, 4,11,16,23, 4,11,16,23, 4,11,16,23 dc.b 6,10,15,21, 6,10,15,21, 6,10,15,21, 6,10,15,21 sin: dc.l $d76aa478, $e8c7b756, $242070db, $c1bdceee, $f57c0faf, $4787c62a dc.l $a8304613, $fd469501, $698098d8, $8b44f7af, $ffff5bb1, $895cd7be dc.l $6b901122, $fd987193, $a679438e, $49b40821, $f61e2562, $c040b340 dc.l $265e5a51, $e9b6c7aa, $d62f105d, $02441453, $d8a1e681, $e7d3fbc8 dc.l $21e1cde6, $c33707d6, $f4d50d87, $455a14ed, $a9e3e905, $fcefa3f8 dc.l $676f02d9, $8d2a4c8a, $fffa3942, $8771f681, $6d9d6122, $fde5380c dc.l $a4beea44, $4bdecfa9, $f6bb4b60, $bebfbc70, $289b7ec6, $eaa127fa dc.l $d4ef3085, $04881d05, $d9d4d039, $e6db99e5, $1fa27cf8, $c4ac5665 dc.l $f4292244, $432aff97, $ab9423a7, $fc93a039, $655b59c3, $8f0ccc92 dc.l $ffeff47d, $85845dd1, $6fa87e4f, $fe2ce6e0, $a3014314, $4e0811a1 dc.l $f7537e82, $bd3af235, $2ad7d2bb, $eb86d391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; implementation of getc, putc and exit ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; putc: movem.l r0-r7,-(sp) move.b r0,_buf eor.l r0,r0 add.l _handle,r0 bne.b _10 moveq.l #-11,-(sp) jsr.l (GetStdHandle) move.l r0,_handle _10: moveq.l #0,-(sp) move.l #_count,-(sp) moveq.l #1,-(sp) move.l #_buf,-(sp) move.l r0,-(sp) jsr.l (WriteFile) or.l r0,r0 movem.l (sp)+,r0-r7 bne.b _20 _30: moveq.l #0,-(sp) move.l #_text,-(sp) move.l #_text,-(sp) moveq.l #0,-(sp) jsr.l (MessageBoxA) moveq.l #0,-(sp) jsr.l (ExitProcess) _20: cmp.l #1,_count bne.b _30 rts.l _buf: dc.b 0 _text: dc.b 'write error',0 even4 _handle:dc.l 0 _count: dc.l 0 getc: movem.l r0-r7,-(sp) eor.l r0,r0 add.l _handle,r0 bne.b _10 moveq.l #-10,-(sp) jsr.l (GetStdHandle) move.l r0,_handle _10: moveq.l #0,-(sp) move.l #_count,-(sp) moveq.l #1,-(sp) move.l #_buf,-(sp) move.l r0,-(sp) jsr.l (ReadFile) or.l r0,r0 movem.l (sp)+,r0-r7 bne.b _20 moveq.l #0,-(sp) move.l #_text,-(sp) move.l #_text,-(sp) moveq.l #0,-(sp) jsr.l (MessageBoxA) moveq.l #0,-(sp) jsr.l (ExitProcess) _20: movu.bl _buf,r0 cmp.l #1,_count beq.b _30 move.l #-1,r0 _30: rts.l _buf: dc.b 0 _text: dc.b 'read error',0 even4 _handle:dc.l 0 _count: dc.l 0 exit: movs.bl r0,r0 move.l r0,-(sp) jsr.l (ExitProcess) ; exit program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; unitialized data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; aa: blk.l 1 bb: blk.l 1 cc: blk.l 1 dd: blk.l 1 buf: blk.b 64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; end of md5.mac ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; .............................................. ; : End of Code : ; .............................................. VSizeOf_text==@-Imagebase-VBaseOf_text @a=@ evencom FileAlignment @=@a FSizeOf_text==@@-FBaseOf_text SizeOfCode==FSizeOf_text ; +--------------------------------------------+ ; | End of .text Section | ; +--------------------------------------------+ ; +--------------------------------------------+ ; | Start of .idat Section | ; +--------------------------------------------+ FBaseOf_idat==@@ VBaseOf_idat==(@-ImageBase+SectionAlignment-1)/SectionAlignment*SectionAlignment BaseOfData==VBaseOf_idat @=ImageBase+VBaseOf_idat ; Insert initialized variables here (and set UseIdatSection=1 ; at the top of this file). Because the code section is set ; r/w-able, you can put initialized variables also into the ; code section. ; var1: dc.l 0 ; var2: dc.l $12345678 VSizeOf_idat==@-Imagebase-VBaseOf_idat @a=@ evencom FileAlignment @=@a FSizeOf_idat==@@-FBaseOf_idat ; +--------------------------------------------+ ; | End of .idat Section | ; +--------------------------------------------+ SizeOfInitializedData==FSizeOf_idat ; +--------------------------------------------+ ; | Start of .udat Section | ; +--------------------------------------------+ FBaseOf_udat==@@ VBaseOf_udat==(@-ImageBase+SectionAlignment-1)/SectionAlignment*SectionAlignment @=ImageBase+VBaseOf_udat ; Insert uninitialized variables here (and set UseUdatSection=1 ; at the top of this file). Because the code section is set ; r/w-able, you can put uninitialized variables also at the END ; of the code section. ; buf1: blk.l 10 ; buf2: blk.l 200 VSizeOf_udat==@-Imagebase-VBaseOf_udat @a=@ evencom FileAlignment @=@a FSizeOf_udat==@@-FBaseOf_udat ; +--------------------------------------------+ ; | End of .udat Section | ; +--------------------------------------------+ SizeOfUninitializedData==VSizeOf_udat SizeOfImage==(@-ImageBase+SectionAlignment-1)/SectionAlignment*SectionAlignment ;#==================================================================# ;# End of Sections # ;#==================================================================# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; End of Win32 version of conv2up.mac ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From: Herbert Kleebauer on 12 Mar 2005 11:05 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; md5.mac ;; ;; calculate md5 hash for stdin (see RFC 1321) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @=$100 bclr.w #10,sr ; clear direction flag for auto increment eor.l r4,r4 ; low bit count eor.l r5,r5 ; high bit count _11: move.l #64,r2 ; read 64 bytes move.l #buf,r6 ; pointer to 64 byte buffer _10: bsr.l getc ; read char from stdin move.b r0,(r6)+-{s1} ; store in buffer and increment pointer cmpq.l #-1,r0 ; end of file beq.b _20 ; yes addq.l #1,r4 ; incr total number of read bytes addcq.l #0,r5 dbf.l r2,_10 ; repeat until 64 bytes read bsr.l md5 ; update md5 hash for 64 bytes read br.b _11 ; next 64 byte block _20: dsl.l #3,r5<r4 ; total number of read bits lsl.l #3,r4 move.b #$80,-1.b(r6) ; replace EOF by $80 _31: move.l r6,-(sp) ; save pointer _30: cmp.l #buf+63,r6 bhi.b _32 move.b #0,(r6) ; fill rest of buffer with 0 inc.l r6 br.b _30 _32: move.l (sp)+,r6 cmp.l #buf+56,r6 ; 8 bytes free in buffer? bls.b _40 ; yes bsr.l md5 ; update md5 hash for 64 bytes in buffer move.l #buf,r6 ; need a fresh 64 byte block br.b _31 _40: move.l r4,buf+56 ; insert bit count in last 8 bytes move.l r5,buf+60 bsr.l md5 ; update md5 hash for 64 bytes in buffer move.l #a,r5 ; pointer to hash value move.l #16,r2 ; 16 byte hash _60: move.b (r5),r0 ; next byte of hash lsr.b #4,r0 ; upper nippel bsr.l _70 ; convert to hex and output move.b (r5)+-,r0 ; get byte again and inc pointer and.b #$0f,r0 ; lower nippel bsr.l _70 ; convert to hex and output dbf.l r2,_60 ; all 16 byte done? bsr.l exit _70: add.b #'0',r0 ; convert to ascii cmp.b #'9',r0 ; lower same '9' bls.b _50 ; yes, then ok add.b #'a'-'9'-1,r0 ; no, convert to a-f _50: bsr.l putc rts.l md5: ; this is a 1:1 implementation of the code in RFC 1321 ; so no documentation is given here move.l r5,-(sp) ; don't modify r4 and r5 move.l a,r0 move.l r0,aa move.l b,r0 move.l r0,bb move.l c,r0 move.l r0,cc move.l d,r0 move.l r0,dd move.l #a,r5 eor.l r3,r3 _10: cmp.b #15,r3 bhi.b _20 move.l 4.b(r5),r0 move.l r0,r1 and.l 8.b(r5),r1 not.l r0 and.l 12.b(r5),r0 or.l r1,r0 br.b _50 _20: cmp.b #31,r3 bhi.b _30 move.l 12.b(r5),r0 move.l r0,r1 and.l 4.b(r5),r1 not.l r0 and.l 8.b(r5),r0 or.l r1,r0 br.b _50 _30: cmp.b #47,r3 bhi.b _40 move.l 4.b(r5),r0 eor.l 8.b(r5),r0 eor.l 12.b(r5),r0 br.b _50 _40: move.l 12.b(r5),r0 not.l r0 or.l 4.b(r5),r0 eor.l 8.b(r5),r0 _50: add.l (r5),r0 movu.bl index(r3),r6 add.l buf(r6*4),r0 add.l sin(r3*4),r0 move.b shift(r3),r2 rol.l r2,r0 add.l 4.b(r5),r0 move.l r0,(r5) move.l r0,16.b(r5) subq.l #4,r5 cmp.l #b0,r5 bhs.b _60 addq.l #16,r5 _60: inc.b r3 cmp.b #64,r3 blo.l _10 move.l aa,r0 add.l r0,a add.l r0,a0 move.l bb,r0 add.l r0,b add.l r0,b0 move.l cc,r0 add.l r0,c add.l r0,c0 move.l dd,r0 add.l r0,d add.l r0,d0 move.l (sp)+,r5 rts.l b0: dc.b $89,$ab,$cd,$ef c0: dc.b $fe,$dc,$ba,$98 d0: dc.b $76,$54,$32,$10 a: dc.b $01,$23,$45,$67 b: dc.b $89,$ab,$cd,$ef c: dc.b $fe,$dc,$ba,$98 d: dc.b $76,$54,$32,$10 a0: dc.b $01,$23,$45,$67 index: dc.b 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 dc.b 1, 6,11, 0, 5,10,15, 4, 9,14, 3, 8,13, 2, 7,12 dc.b 5, 8,11,14, 1, 4, 7,10,13, 0, 3, 6, 9,12,15, 2 dc.b 0, 7,14, 5,12, 3,10, 1, 8,15, 6,13, 4,11, 2, 9 shift: dc.b 7,12,17,22, 7,12,17,22, 7,12,17,22, 7,12,17,22 dc.b 5, 9,14,20, 5, 9,14,20, 5, 9,14,20, 5, 9,14,20 dc.b 4,11,16,23, 4,11,16,23, 4,11,16,23, 4,11,16,23 dc.b 6,10,15,21, 6,10,15,21, 6,10,15,21, 6,10,15,21 sin: dc.l $d76aa478, $e8c7b756, $242070db, $c1bdceee, $f57c0faf, $4787c62a dc.l $a8304613, $fd469501, $698098d8, $8b44f7af, $ffff5bb1, $895cd7be dc.l $6b901122, $fd987193, $a679438e, $49b40821, $f61e2562, $c040b340 dc.l $265e5a51, $e9b6c7aa, $d62f105d, $02441453, $d8a1e681, $e7d3fbc8 dc.l $21e1cde6, $c33707d6, $f4d50d87, $455a14ed, $a9e3e905, $fcefa3f8 dc.l $676f02d9, $8d2a4c8a, $fffa3942, $8771f681, $6d9d6122, $fde5380c dc.l $a4beea44, $4bdecfa9, $f6bb4b60, $bebfbc70, $289b7ec6, $eaa127fa dc.l $d4ef3085, $04881d05, $d9d4d039, $e6db99e5, $1fa27cf8, $c4ac5665 dc.l $f4292244, $432aff97, $ab9423a7, $fc93a039, $655b59c3, $8f0ccc92 dc.l $ffeff47d, $85845dd1, $6fa87e4f, $fe2ce6e0, $a3014314, $4e0811a1 dc.l $f7537e82, $bd3af235, $2ad7d2bb, $eb86d391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; implementation of getc, putc and exit ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; getc: eor.l r0,r0 movem.l r0-r7,-(sp) move.w #$3f00,r0 lea.w 28.b(r7),r1 move.w #1,r2 eor.w r3,r3 trap #$21 bcs.b exit cmp.w r0,r2 movem.l (sp)+,r0-r7 beq.b _10 move.l #-1,r0 _10: rts.l putc: movem.l r0-r7,-(sp) move.w #$4000,r0 lea.w 28.b(r7),r1 move.w #1,r2 move.w r2,r3 trap #$21 bcs.b exit cmp.w r0,r2 bne.b exit movem.l (sp)+,r0-r7 rts.l exit: move.b #$4c,m0 trap #$21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; unitialized data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; aa: blk.l 1 bb: blk.l 1 cc: blk.l 1 dd: blk.l 1 buf: blk.b 64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; end of md5.mac ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From: Betov on 12 Mar 2005 11:40 Herbert Kleebauer <klee(a)unibwm.de> ýcrivait news:423312B4.2D38D3B5 @unibwm.de: OhOh!... ;) 3 Posts at once. Did i touch you where it hurts you, Herbert? :)) > Betov wrote: >> Herbert Kleebauer <klee(a)unibwm.de> ýcrivait news:4232D11F.A23FD459 > >> > It is not fair to tell this old but wrong fairytale >> > to newcomer. >> >> Yes, it _is_ fair. The opposite is evidently unfair. > > Then it is also fair to let you in the wrong believe, > that there is an "assembly rebirth"? Well, no relationship, at all, with the actual discussion, but, if you'd like to know, i do not "believe". This is a word i gladly let to the religious dements. For me, i can "know", i can "ignore", i can "suppose", i can 'guess",... but i cannot "believe". I do the job that i consider necessary to be done for having an effective "Assembly Rebirth". Do i think that it will _succeed_? Though this is not my problem, i would rather bet on... no. Propaganda, lies and swindlings are way more powerfull than any fact. If there was the smaller relationship between the facts qualities and the success rate, an indivildual like Randall Hyde could never exist. If there was any seriousness and intellectual real value, in the Programming area, C would have never existed, as well. We have to live in a world where a G.W. Bush can be re-elected, you know... in a world where the majority of the european citizens are going to vote 'yes' to a Constitution that will be the last weapon for the final destruction of the European civilization by making it an open field for wild capitalism, americanization, auto-ethonocide, and so on... So, will the "Assembly Rebirth" succeed... :( >> > DOS doesn't restrict you in any way to >> > to 16 bit operand size or 16 bit addressing modes >> > and you are also not bound to real/v86 mode. >> >> Then how is it that 99,999999...% of Dos posted examples >> are 16 Bits .com Files? > > You still didn't get it. The posted code can be assembled > as 16 bit com program or as 32 bit Windows program without > any change in the source code. CPU instructions are far below > the OS level, the CPU executes the given instructions and > doesn't care about the OS. Assembly programming is pretty > independent of the OS or CPU mode (real/v86/protected mode). ???!!!... _You_ still don't get that, if your code can go as well 16 Bits com program and 32 bits Windows program, there is no more any reason for not going the actually used OS way. You can twist the "problem" the way you'd like to see it: What you have shown here is exactly the demonstration that there is no reason for taking any care of any dead DOS. Betov. < http://rosasm.org/ >
From: Tom on 12 Mar 2005 12:20 Dear Mr. Hyde, Please, should I take the paragraph boundary for granted? There is an explanation, is there? Thank you very much. Tom
From: Tom on 12 Mar 2005 12:24
NoDot wrote: > It's how real mode operates. Intel chose this mode because it's an easy > way to extend the memory to 1M without much complexity. Now, why? Technically why? Thank you. Tom |