| | |
Doesn't work, any idea?
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2008
Posts: 4
Reputation:
Solved Threads: 0
It is meant to count the first two numbers in the array and then place them in ascending order, but sth wrong. Any idea?
assembly Syntax (Toggle Plain Text)
Code segment jmp main add1 dw 9,3,2,7,1,4,2,5,8,1 main: mov si,0 call orderab exit: mov ax,04c00h int 21h orderab: cmp add1[si],add1[si+2] jle finish mov ax,add1[si] mov bx,add1[si+2] mov add1[si],bx mov add1[si+2],ax finish: ret
Last edited by Ancient Dragon; Dec 7th, 2008 at 7:54 pm. Reason: add code tags
You're telling it to compare two elements away from the first one, being the third one not the second one.
http://www.geocities.com/SiliconVall.../asml1012.html
http://www.geocities.com/SiliconVall.../asml1012.html
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
•
•
Join Date: Dec 2008
Posts: 4
Reputation:
Solved Threads: 0
I managed to make it work but it only compares the first two elements of the array, i want it to keep comparing until it gets to the end of the array...
Assembly Syntax (Toggle Plain Text)
Code segment jmp main add1 dw 9,3,2,7,1,4,2,5,8,1 main: mov si,0 call orderab exit: mov ax,04c00h int 21h orderab: mov ax,add1[si] cmp ax,add1[si+2] jle finish mov bx,add1[si+2] mov add1[si],bx mov add1[si+2],ax finish: ret
Last edited by Ancient Dragon; Dec 8th, 2008 at 2:08 pm. Reason: add code tags
•
•
Join Date: Dec 2008
Posts: 4
Reputation:
Solved Threads: 0
ode segment
jmp main
add1 dw 9,3,2,7,1,4,2,5,8,1
main: call order
exit: mov ax,04c00h
int 21h
order: mov cx,10
loop: mov si,0
dec cx
cmp cx,0
jz exit
call orderab
jmp loop
orderab: mov dx,9
loop1: dec dx
mov ax,add1[si]
cmp ax,add1[si+2]
jle finish
mov bx,add1[si+2]
mov add1[si],bx
mov add1[si+2],ax
finish: inc si
inc si
cmp dx,0
jnz loop1
ret
Any idea why it doesn't work?
jmp main
add1 dw 9,3,2,7,1,4,2,5,8,1
main: call order
exit: mov ax,04c00h
int 21h
order: mov cx,10
loop: mov si,0
dec cx
cmp cx,0
jz exit
call orderab
jmp loop
orderab: mov dx,9
loop1: dec dx
mov ax,add1[si]
cmp ax,add1[si+2]
jle finish
mov bx,add1[si+2]
mov add1[si],bx
mov add1[si+2],ax
finish: inc si
inc si
cmp dx,0
jnz loop1
ret
Any idea why it doesn't work?
![]() |
Similar Threads
- Requesting shadowing work at home job (Software Development Job Offers)
- My Flash does not work online (Graphics and Multimedia)
- Help with idea (IT Professionals' Lounge)
- Help, page won't work in IE (HTML and CSS)
- monitor power button not responding (Monitors, Displays and Video Cards)
- Can't Get Flash To Work (Windows 95 / 98 / Me)
- IE 6 Window from link won't load. (Web Browsers)
- USB Printer won't work (Windows NT / 2000 / XP)
- Where do you most of your work? (*nix Software)
- Can't get multimedia keys to work on mac keyboard (Apple Hardware)
Other Threads in the Assembly Forum
- Previous Thread: Why can't I use labels ?
- Next Thread: (Newbie question) Variable problem
Views: 767 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





