Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-30-2003, 12:27 AM   #1
Member (7 bit)
 
lokgotz's Avatar
 
Join Date: Mar 2002
Location: Malaysia
Posts: 75
Question assembly language....need help!

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.....
lokgotz is offline   Reply With Quote
Old 03-30-2003, 08:29 PM   #2
Member (12 bit)
 
Paul Victorey's Avatar
 
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)
Paul Victorey is offline   Reply With Quote
Old 03-30-2003, 10:38 PM   #3
Member (7 bit)
 
LoveJones's Avatar
 
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.
LoveJones is offline   Reply With Quote
Old 03-31-2003, 08:01 AM   #4
Member (7 bit)
 
lokgotz's Avatar
 
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
lokgotz is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:56 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2