Re: Official release of the Twelve Assembly Lessons
- From: Evenbit <nbaker2328@xxxxxxxxxxx>
- Date: Sun, 15 Jul 2007 17:47:14 -0700
On Jul 14, 9:53 am, Frank Kotler <fbkot...@xxxxxxxxxxx> wrote:
I rewrite everything in RosAsm
Would you consider posting some of your rewrites so other RosAsm users
could add 'em to their personal clip-file? I'm not suggesting that you
should be anybody's "lackey" and crank this stuff out for them, but if
you've got it written anyway, why not share?
Seems that folk like to complain but are afraid to post code. Perhaps
a demo will encourage them?
This is in HLA and only sorts numbers:
program numBubble;
#include( "stdlib.hhf" )
type
sorter:
class
var
nums :byte[16];
count :dword;
endvar;
procedure create; @returns( "esi" );
method destroy;
method append( num:byte );
method dump;
method sort;
endclass;
endtype;
procedure sorter.create;
begin create;
push( eax );
if ( esi = 0 ) then
mem.alloc( @size( sorter ) );
mov( eax, esi );
endif;
mov( &sorter._VMT_, this._pVMT_ );
sub( eax, eax );
mov( eax, this.count );
pop( eax );
end create;
method sorter.destroy; @nodisplay;
begin destroy;
if ( isInHeap( esi ) ) then
mem.free( esi );
endif;
end destroy;
method sorter.append( num:byte ); @nodisplay;
begin append;
push( eax );
push( ebx );
push( ecx );
mov( num, al );
mov( this.count, ebx );
lea( ecx, this.nums );
mov( al, [ecx + ebx] );
add( 1, ebx );
mov( ebx, this.count );
pop( ecx );
pop( ebx );
pop( eax );
end append;
method sorter.dump; @nodisplay;
begin dump;
push( ecx );
push( ebx );
push( eax );
lea( ebx, this.nums );
stdout.puts( " " );
for( mov( 0, ecx ); ecx < this.count; add( 1, ecx ) ) do
mov( [ebx + ecx], al );
stdout.putu8( al );
stdout.puts( " " );
endfor;
stdout.newln();
pop( eax );
pop( ebx );
pop( ecx );
end dump;
method sorter.sort; @nodisplay;
var
j :dword;
k :dword;
begin sort;
push( eax );
push( ebx );
push( ecx );
push( edx );
lea( ebx, this.nums );
mov( this.count, edx );
sub( 2, edx );
for( mov( 0, j ); j <= edx; inc( j ) ) do
push( edx );
mov( j, ecx );
stdout.put( cl, "- " );
mov( this.count, edx );
sub( ecx, edx );
sub( 2, edx );
for( mov( 0, k ); k <= edx; inc( k ) ) do
push( edx );
mov( k, ecx );
mov( ecx, edx );
inc( edx );
mov( [ebx + ecx], al );
mov( [ebx + edx], ah );
if ( al > ah ) then
mov( ah, [ebx + ecx] );
mov( al, [ebx + edx] );
endif;
pop( edx );
endfor;
for( mov( 0, ecx ); ecx < this.count; inc( ecx ) ) do
mov( [ebx + ecx], al );
stdout.putu8( al );
stdout.puts( " " );
endfor;
stdout.newln();
pop( edx );
endfor;
pop( edx );
pop( ecx );
pop( ebx );
pop( eax );
end sort;
readonly
VMT( sorter );
endreadonly;
var
b :sorter;
begin numBubble;
rand.randomize();
b.create();
for( mov( 0, ecx ); ecx < 16; inc( ecx ) ) do
rand.urange( 0, 255 );
b.append( al );
endfor;
b.dump();
b.sort();
b.dump();
b.destroy();
end numBubble;
Nathan.
.
- Follow-Ups:
- Re: Official release of the Twelve Assembly Lessons
- From: Frank Kotler
- Re: Official release of the Twelve Assembly Lessons
- References:
- Re: Official release of the Twelve Assembly Lessons
- From: Betov
- Re: Official release of the Twelve Assembly Lessons
- From: santosh
- Re: Official release of the Twelve Assembly Lessons
- From: rhyde@xxxxxxxxxx
- Re: Official release of the Twelve Assembly Lessons
- From: JGCASEY
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: JGCASEY
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: JGCASEY
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: Betov
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: Betov
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: Betov
- Re: Official release of the Twelve Assembly Lessons
- From: Julienne Walker
- Re: Official release of the Twelve Assembly Lessons
- From: Frank Kotler
- Re: Official release of the Twelve Assembly Lessons
- Prev by Date: Re: ASM routines for WIN 32 Clipboard
- Next by Date: Re: Blair, another one bites the dust !
- Previous by thread: Re: Official release of the Twelve Assembly Lessons
- Next by thread: Re: Official release of the Twelve Assembly Lessons
- Index(es):
Relevant Pages
|
|