APJ #9 is almost finished, but a couple of "Assembly Snippets" are still needed (and something for the "Issue Challenge"). Would anyone be willing to submit some pieces of great code so that this issue can be out as soon as possible?

Thanks in advance,

Tiago Sanches
Posted on 2001-08-17 09:20:17 by Tiago Sanches
What exactly is APJ (internet/paper, etc.). What kind of snippets (DOS/Win32, etc.)?
Posted on 2001-08-18 22:12:34 by eet_1024
Is it the same one as this one?

http://asmjournal.freeservers.com/
Posted on 2001-08-18 23:29:35 by Torch
Wow. I used to write stuff for APJ, until they stopped publishing them.


(Actually, I just made the last issue.)


Sorry, no code snippetts available offhand. But if you DO get it back up, I'd do an 'Intro to playing with your PIC" art.
Posted on 2001-08-18 23:44:56 by Ernie
I dont have any snippets, but i got some suggestions. How about making assembly versions of the standerd C libarary using no o/s specific functions (int 21h, etc...)
Posted on 2001-08-19 16:18:25 by ChimpFace9000
Ernie, he is putting it back..so start writting that PIC paper pleaseeeeeeeeeee :)

Latigo
Posted on 2001-08-19 16:33:28 by latigo
Ok heres some snippets. I wrote these. They are probably pretty crappy, but they might be of use to some one.
Posted on 2001-08-19 17:43:34 by ChimpFace9000
Maybe you could try and convince Steve Gibson (http://grc.com/steve.htm) form www.grc.com to write an article or tutorial.
Posted on 2001-08-20 13:52:25 by ChimpFace9000
Here are some CGI progs to test concepts in asm (MZ format). Can be ran without server. You can place them into a cgi directory or set a script alias to them.
Posted on 2001-08-20 23:44:09 by eet_1024
Converts the given string to lowercase...

Sorry, I am an asm newbie, so this is all I could come up with after a few days of trying to learn.
Posted on 2001-08-21 13:29:57 by vcv
Sorry for the dealy in reply but I was out of town for a few days.
Good news, APJ #9 will most probably be out before the end of August if everything goes according to plan!

Here are some replies:

eet_1024: Check the past APJ issues to find out what it is all about. Thanks for the CGI progs, but those don't really count as snippets though :( Maybe you could write a small article on the subject using the files you posted here :)

Torch: Yes, APJ is the one at http://asmjournal.freeservers.com!!!

Ernie: That would be great. Check the APJ site for guidelines on how to write the articles (in case you have forgotten them) and make sure that anything you're writting hasn't been published before! :)

ChimpFace9000: Up until issue #4 Xbios2 was doing a column called "The C standard library in Assembly" but it has ended. If you want to continue his footsteps, please do so! And thanks for the snippets, it was something like that I was looking for!

vcv: I'll give your snippet a look and we'll see :) don't place invoke's and include's and bla, bla, bla in a snippet though. Check the APJ issues for a general view of how they should be...

Thanks everyone,

Tiago Sanches
Posted on 2001-08-21 16:22:41 by Tiago Sanches
I think, for many serious asm (and not only asm) programmers
would be interesting new implementation of useful classical
algorithm.
So, fortunatly, we all have seen recent new realisations of BM algorithm:
2 - by Hutch
1 - by bulyNaza

With their permission I would recommend to publish all three
procedures as three different approaches to one of most important task - binary string search.

This is interesting not only to Win32asm programmers -
but to any programmer working in x86 32 bit machine.
With both scientific algorithmic point of view and proctical usage.
Posted on 2001-08-22 06:07:21 by The Svin
The Svin: That would be great, if you want send me the files or post them here at the board in the next few days. Thanks!
Posted on 2001-08-22 15:41:33 by Tiago Sanches
Heres some of the basic trig functions not directly supported on the FPU. If you want them.
Posted on 2001-08-22 17:12:03 by Eóin
Tiago Sanches:
   I'll create a CGI message board using 32bit PE console format. It'll highlight STDIO, Environment variables, Forms, and file I/O. I wrote a similar app in PERL when I was first learning CGI. I'll try to comment the hell out of it. When is issue 9 & 10 coming out?
Posted on 2001-08-23 00:16:55 by eet_1024
Here is a simple CGI Tutoria - I even wrote an article on it:
Posted on 2001-08-23 07:40:11 by eet_1024
Just a thought that there might some interrest for a tutorial that covers serial/parrallel port controlling for the outside world. Ie for robotics or similar.
Cheers

fiddler:alright:
Posted on 2001-08-23 16:41:05 by fiddler
The Svin, thanks!

Tiago Sanches,
I agree with The Svin and here is the code:

; Fastest binary string search algo with

; PPlain and PMMX type of processors
; <c> 2001 by buliaNaza ;
; ;
.data? ;
align 4 ; !!!
skip_table DD 256 Dup(?) ; skip table
; ;
;.................................;
; Usage: esi ->pBuffer ; esi->buffer with bytes to be searched through
; ebp = lenBuffer ; ebp =length of the buffer
; ebx ->pSrchData ; ebx->pointer to data to be searched for
; edx = lenSrchData ; edx=length of data to be searched for
; edi ->pskip_table ; edi->pointer to skip table (must be aligned)
; call BMCaseSNext ;
;.......................................;
.code ;
BMCaseSNext: ;
cmp edx, 4 ; edx = length of data to be searched for
jg Boyer_Moore ;
;... Brute Force Search ................; for 4 digits or less only!
mov edi, [ebx] ; edi = dword of data to be searched for
mov ecx, 5 ;
sub ecx, edx ;
lea eax, [esi+edx-1] ; eax->new starting address in pBuffer
shl ecx, 3 ; *8
mov bl, [ebx+edx-1] ; get last byte only
mov bh, bl ; copy in bh
bswap edi ;
shr edi, cl ;
add ebp, esi ; ebp ->end of buffer
and ebx, 0FFFFh ; ebx = need the bx word only
mov ecx, ebx ;
mov esi, edx ; esi=edx = length of data to be searched for
shl ecx, 16 ;
test eax, 3 ;
lea ebx, [ebx+ecx] ;
jz Search_2 ;
Unalign_1: ;
cmp eax, ebp ; ebp ->end of buffer
jge Not_found ;
mov cl, [eax] ;
inc eax ;
cmp cl, bl ;
jz Compare_1 ;
Search_1: ;
test eax, 3 ;
jnz Unalign_1 ;
Search_2: ;
cmp eax, ebp ;u ebp ->end of buffer
jge Not_found ;v
mov ecx, [eax] ;u scasb for the last byte from pSrchData
add eax, 4 ;v
xor ecx, ebx ;u
mov edx, 7EFEFEFFh ;v
add edx, ecx ;u
xor ecx, -1 ;v
xor ecx, edx ;u
mov edx, [eax-4] ;v
and ecx, 81010100h ;u
jz Search_2 ;v
;
cmp dl, bl ;
jz Minus_4 ;
cmp dh, bl ;
jz Minus_3 ;
shr edx, 16 ;
cmp dl, bl ;
jz Minus_2 ;
cmp dh, bl ;
jz Compare_1 ;
jnz Search_2 ;
Minus_2: ;
dec eax ;
jnz Compare_1 ;
Minus_4: ;
sub eax, 3 ;
jnz Compare_1 ;
Minus_3: ;
sub eax, 2 ;
Compare_1: ;
mov edx, edi ;
cmp eax, ebp ; ebp ->end of buffer
jg Not_found ;
cmp esi, 1 ;
jz Found_1 ;
cmp dl, [eax-2] ; eax->pBuffer
jnz Search_1 ;
cmp esi, 2 ;
jz Found_1 ;
cmp dh, [eax-3] ; eax->pBuffer
jnz Search_1 ;
cmp esi, 3 ;
jz Found_1 ;
shr edx, 16 ;
mov cl, [eax-4] ; eax->pBuffer
cmp dl, cl ;
jnz Search_1 ;
Found_1: ;
sub eax, esi ; in eax->pointer to 1st
ret ; occurrence of data found in pBuffer
;...Boyer Moore Case Sens Next Search...;
Boyer_Moore: ;
add esi, ebp ; esi->pointer to the last byte of pBuffer
lea ebx, [ebx+edx-1] ; ebx->pointer to the last byte of pSrchData
neg edx ; edx= -lenSrchData
mov ecx, edx ; ecx = edx = -lenSrchData
add ebp, edx ; sub lenSrchData from lenBuffer
mov eax, 256 ; eax = counter
xor ebp, -1 ; not ebp->current negative index
MaxSkipLens: ;
mov [eax*4+edi-4], edx ; filling up the skip_table with -lenSrchData
mov [eax*4+edi-8], edx ;
mov [eax*4+edi-12], edx ;
mov [eax*4+edi-16], edx ;
mov [eax*4+edi-20], edx ;
mov [eax*4+edi-24], edx ;
mov [eax*4+edi-28], edx ;
mov [eax*4+edi-32], edx ;
mov [eax*4+edi-36], edx ;
mov [eax*4+edi-40], edx ;
mov [eax*4+edi-44], edx ;
mov [eax*4+edi-48], edx ;
mov [eax*4+edi-52], edx ;
mov [eax*4+edi-56], edx ;
mov [eax*4+edi-60], edx ;
mov [eax*4+edi-64], edx ;
mov [eax*4+edi-68], edx ;
mov [eax*4+edi-72], edx ;
mov [eax*4+edi-76], edx ;
mov [eax*4+edi-80], edx ;
mov [eax*4+edi-84], edx ;
mov [eax*4+edi-88], edx ;
mov [eax*4+edi-92], edx ;
mov [eax*4+edi-96], edx ;
mov [eax*4+edi-100], edx ;
mov [eax*4+edi-104], edx ;
mov [eax*4+edi-108], edx ;
mov [eax*4+edi-112], edx ;
mov [eax*4+edi-116], edx ;
mov [eax*4+edi-120], edx ;
mov [eax*4+edi-124], edx ;
mov [eax*4+edi-128], edx ;
sub eax, 32 ;
jne MaxSkipLens ; loop while eax=0
SkipLens: ;
mov al, [ecx+ebx+1] ;u filling up with the real negative offset of every
inc ecx ;v byte from the pSrchData, starting from the last to
mov [eax*4+edi], ecx ;u the first, at the offset in skip_table equal to the
jne SkipLens ;v ASCII code of the byte, multiplied by 4
Search: ; the main searching loop-> FAST PART
mov al, [esi+ebp] ;u get a byte from pBuffer ->esi +ebp
mov ecx, edx ;v ecx=edx= -lenSrchData
sub ebp, [eax*4+edi] ;u sub negative offset for this byte from skip_table
jc Search ;v if dword ptr [eax*4+edi] AND ebp <> 0 loop again
lea ebp, [ebp+esi+1] ;u current negative index -> next byte (+1)
jge Not_found ;v end of pBuffer control (if ebp>=0 end)
; compare previous bytes from pSrchData (->ebx)
Compare: ; and current offset in pBuffer (->ebp)->SLOW PART
mov eax, [ebx+ecx+1] ; one dword from pSrchData -> ebx
inc ecx ; ecx = -lenSrchData
jz Found ; if ecx = 0 Found&Exit
cmp al, [ebp+ecx-1] ; ebp->pBuffer
jnz Not_equal ;
inc ecx ; ecx = -lenSrchData
jz Found ; if ecx = 0 Found&Exit
cmp ah, [ebp+ecx-1] ; ebp->pBuffer
jnz Not_equal ;
inc ecx ; ecx = -lenSrchData
jz Found ; if ecx=0 Found&Exit
shr eax, 16 ;
inc ecx ;
cmp al, [ebp+ecx-2] ; ebp->pBuffer
jnz Not_equal ;
test ecx, ecx ; ecx = -lenSrchData
jz Found ; if ecx=0 Found&Exit
cmp ah, [ebp+ecx-1] ; ebp->pBuffer
jz Compare ;
Not_equal: ;
sub eax, eax ; eax = 0
sub ebp, esi ; restore ebp->current negative index
jl Search ; end of pBuffer control
Not_found: ;
or eax, -1 ; Exit with flag Not_Found eax=-1
ret ;
Found: ;
lea eax, [ebp+edx] ; in eax->pointer to 1st
ret ; occurrence of data found in pBuffer
Posted on 2001-08-23 20:30:53 by buliaNaza
buliaNaza & The Svin: Thanks, now got both your codes and now I'm going to mail Hutch to see if I can use his, and voila! we have an issue challenge for #9 and it be complete!! :)

Thanks guys,

Tiago Sanches
Posted on 2001-08-25 15:40:42 by Tiago Sanches
Tiago,

I have the three latest versions ready to publish and have the documentation written up for them, it contains a description of how a generic Boyer Moore search algorithm works, the code and design considerations of implementing them in assembler and two variations that are based on the two seperate shifts used, a Horspool style variation and a simplified version.

There is explanation of the 2 variations and how they perform on different processors.

I will allow the complete document to be published but will not allow any modification of either the algorithms or the documentation attached to them.

Let me know if you are interested, the algorithms are Copyright MASM32 and are intended for the next version.

Regards,

hutch@pbq,com.au
Posted on 2001-08-26 02:03:35 by hutch--