|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
Join Date: Mar 2002
Location: Malaysia
Posts: 75
|
hi guys...i hope u guys can help me in this.....
title Sort Program (Sort.asm) ; This program performs a bubble sorting dosseg .model small .stack 1000h .data num dw 10 dup (?) m dw ? n dw ? temp dw ? inputkey db 3 db ? db 3 dup (?) message1 db 'Please enter 10 numbers : ', 0ah, 0dh, '$' .code main proc mov ax, @data mov ds, ax mov ah, 9 mov dx, offset message1 int 21h again1: mov cx, 00ah mov ah, 0ah mov dx, offset inputkey int 21h LEA Si, num LEA bx, inputkey dec cx jmp again1 inc bx mov ch, 0 mov cl, [bx] inc bx AGAIN : mov Al, [bx] mov [SI] , AL inc bx inc SI Loop AGAIN main endp end main its causing an infinite loop.......can anyone try to debug this please....i have sleepless night doing this.....its my assignment and its due monday..... |
|
|
|
|
|
#2 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
This is an infinite loop here:
again1: mov cx, 00ah mov ah, 0ah mov dx, offset inputkey int 21h LEA Si, num LEA bx, inputkey dec cx jmp again1 the last line will always return you to the first, with no way to end the loop. You probably want some kind of conditional jump instead of the nonconditional, but I don't know what that first loop is supposed to do, so I can't say. I think you PROBABLY want to set cx outside of the loop (cx is your loop counter?) and you want to jgz at the end (so you jump until cx is zero after all the decrements) |
|
|
|
|
|
#3 |
|
Member (7 bit)
Join Date: Sep 2002
Posts: 93
|
Big tip is to write out the code you are trying to write in a language you know like C, and translate it directly into assembly. It will save you a lot of time and a lot of logical errors like infinite loops.
Assembly is way too complicated to really gung-ho it. |
|
|
|
|
|
#4 |
|
Member (7 bit)
Join Date: Mar 2002
Location: Malaysia
Posts: 75
|
paul: thanks....that's the problem i found out....i kinda fixed it....but it doesn't sort properly....i asked another friend of mine to debug..thanks for your help!
loveJones: i have the C++ program for this code....but the thing is whenever i click on the convert button, the compiler seems to have some problem coverting it....thanks anyway |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|