News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem solved, can close now.

Started by Mike Amer, April 29, 2008, 11:21:16 PM

Previous topic - Next topic

Mike Amer

Problem solved.  Thanks!

hutch--

This sounds like homework for a school assignment Mike. Tell us what you are trying to do and show us your code and someone may be able to help you.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mike Amer

#2
Problem solved.  Thanks!

MichaelW

I won't provide much in the way of code, but I do have a few suggestions.

It would be much easier to develop your sorting code in a separate source, using a small number of short null-terminated strings defined in the initialized data section. If you can depend on the strings always being the same length then accessing/manipulating them directly should be no problem. Otherwise, I think you should use a pointer array, and if you are allowed to do so sort only the pointer array.

.data
  str1 db "tango",0
  str2 db "romeo",0
  str3 db "delta",0
  str4 db "alpha",0
  ptrs dd str1,str2,str3,str4


Select one of the simpler, well established, well understood sorting algorithms and convert it to assembler. I would select a gnome sort or a bubble sort for this. It would probably be easier to start with code that sorts an integer array, and then once you get it working modify it to sort strings. If you are allowed to do so, in the sort routine use the Irvine Str_compare procedure to compare the strings. If it works as the comments indicate, you could use the returned flags in the same way as the returned flags for the CMP instruction.
eschew obfuscation

kermit

Hi,

nice little exercise, though i don't want to do somebody elses homework i tried to do it myself, because i'm too still learning  :wink
( i omitted the string input part so it's not exactly  the solution )

i must admit i had some problems with the part of exchanging the pointers, i first wanted to handle that in my proc , but had difficulties, so i did that after the proc call.
it's definately a good exercise for beginners, so u should try to solve it yourself and only look for a comparison after u finished it yourself ( or are really desperate  :dazzled: ) ...

greetz,

kermit

[attachment deleted by admin]

NightWare

#5
hi,
a bit complicate for a homeworks... not only because of use of a LUT for pointers, or to quickly exchange them, but also because you have to take care about case sensitive problem... nice, and quite complete work to do...

here, how i personnally do the job, you must exchange the strings pointers, but do it in a clever way, alternate the couple of strings (for speed) :

; 9 2 2 2 2 2 2 2 2 1
;  }   }   }   }   }
; 2 9 4 4 4 4 3 3 1 2
;    }   }   }   }
; 7 4 9 5 5 3 4 1 3 3
;  }   }   }   }   #
; 4 7 5 9 3 5 1 4 4 4
;    }   }   }   }
; 5 5 7 3 9 1 5 5 5 5
;  }   }   }   }   #
; 6 6 3 7 1 9 6 6 6 6
;    }   }   }   }
; 3 3 6 1 7 6 9 7 7 7
;  }   }   }   }   #
; 8 8 1 6 6 7 7 9 8 8
;    }   }   }   }
; 1 1 8 8 8 8 8 8 9 9


where "}" represent the work to do, and "#" are the useless work for a non-pair number of strings...  :wink


Edit : you need to loop entirely n*number of string... the previous example is the result of an optimisation to avoid useless work... (completely forgotten that one...) and nobody corrected me...  :(
; 9  8  8  6  6  4  4  2  2  1
;  }     }     }     }     }
; 8  9  6  8  4  6  2  4  1  2
;     }     }     }     }
; 7  6  9  4  8  2  6  1  4  3
;  }     }     }     }     }
; 6  7  4  9  2  8  1  6  3  4
;     }     }     }     }
; 5  4  7  2  9  1  8  3  6  5
;  }     }     }     }     }
; 4  5  2  7  1  9  3  8  5  6
;     }     }     }     }
; 3  2  5  1  7  3  9  5  8  7
;  }     }     }     }     }
; 2  3  1  5  3  7  5  9  7  8
;     }     }     }     }
; 1  1  3  3  5  5  7  7  9  9


; 10  9  9  7  7  5  5  3  3  1  1
;  }     }     }     }     }
; 9 10  7  9  5  7  3  5  1  3  2
;     }     }     }     }     }
; 8  7 10  5  9  3  7  1  5  2  3
;  }     }     }     }     }
; 7  8  5 10  3  9  1  7  2  5  4
;     }     }     }     }     }
; 6  5  8  3 10  1  9  2  7  4  5
;  }     }     }     }     }
; 5  6  3  8  1 10  2  9  4  7  6
;     }     }     }     }     }
; 4  3  6  1  8  2 10  4  9  6  7
;  }     }     }     }     }
; 3  4  1  6  2  8  4 10  6  9  8
;     }     }     }     }     }
; 2  1  4  2  6  4  8  6 10  8  9
;  }     }     }     }     }
; 1  2  2  4  4  6  6  8  8 10 10

MichaelW

Thank you Mike, for being so thoughtful and considerate. Now that you have removed the context for the replies they make no sense, so they are of no further use for anyone.
eschew obfuscation