The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: eax on March 26, 2006, 01:23:28 AM

Title: Re: need help
Post by: eax on March 26, 2006, 01:23:28 AM
Hello ,


I am fresher in assembly language( 80*86) .

Could you please give me any clue , how to write Bubble sort in assembly language.

Any suggestion would be helpful.

I am trying hard but when i run my program it prints all 0's instead of numbers in asscending order.

Title: Re: need help
Post by: hutch-- on March 26, 2006, 08:43:22 AM
This sounds a lot like a homework assignment. All you need to do is learn to write assembler code and then code up a bubble sort if you can actually find a use for one.
Title: Re: need help
Post by: dsouza123 on March 26, 2006, 03:58:12 PM
If your problem is understanding the bubble sort algorithm
then tracing through this unoptimized/simplified pascal example may help.


var
  i,j,s,d,t : longword;
  A : array[0..7] of longword;

begin
  A[0] := 7; A[1] := 6; A[2] := 5; A[3] := 4;
  A[4] := 3; A[5] := 2; A[6] := 1; A[7] := 0;

  i := 0;
  j := 7;
  repeat
    write(A[i]:2);
    i := i + 1;
  until i > j;
  writeln;

  j := 7;
  repeat
    i := 1;
    repeat
      s := A[i];
      d := A[i-1];
      if s < d then begin
        t := s; s := d; d := t;
        A[i]   := s;
        A[i-1] := d;
      end;
      i := i + 1;
    until i > j;
    j := j - 1;
  until j = 0;

  i := 0;
  j := 7;
  repeat
    write(A[i]:2);
    i := i + 1;
  until i > j;
  writeln;
end.
Title: Re: need help
Post by: IAO on March 26, 2006, 04:05:19 PM
Hi to all:  My English is poor. But I try.

Mr. eax: You can see here:
http://webster.cs.ucr.edu/
The Art of Assembly Language. Chapter 12.

Thanks.
Bye ('_').


Title: Re: need help
Post by: eax on April 03, 2006, 07:48:23 PM
thanks for ur help .

I am done with bubble sort in assembly language,

now i need to write a program to test if a string is palindrome or not.

please give me any clue to start with it.
Title: Re: need help
Post by: Mark Jones on April 03, 2006, 09:01:15 PM
http://www.catb.org/~esr/faqs/smart-questions.html

http://dictionary.reference.com/search?r=2&q=palindrome

Use the search box at the top, search for "String reverse" then "String compare."