Cell Phones | Montana Music | Proxy | Property for sale in Spain | MPAA
assembly language....need help! [Archive] - PCMech Forums

PDA

View Full Version : assembly language....need help!


lokgotz
03-30-2003, 01:27 AM
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.....

Paul Victorey
03-30-2003, 09:29 PM
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)

LoveJones
03-30-2003, 11:38 PM
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.

lokgotz
03-31-2003, 09:01 AM
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