tahsgh
Messages postés22Date d'inscriptionjeudi 17 avril 2008StatutMembreDernière intervention15 novembre 2010
-
26 avril 2010 à 00:52
cs_patatalo
Messages postés1466Date d'inscriptionvendredi 2 janvier 2004StatutModérateurDernière intervention14 février 2014
-
28 avril 2010 à 20:31
salam;
jai le code suivant
-----------------------------------------
global main
SECTION . text
main :
jmp start
data: dw 60, 55, 45, 50, 40, 35, 25, 30, 10, 0
data2: dw 328, 329, 898, 8923, 8293, 2345, 10, 877, 355, 98
dw 888, 533, 2000, 1020, 30, 200, 761, 167, 90, 5
swapflag: db 0
swap: push ax ; save old value of ax
mov ax, [bx+si] ; load first number in ax
xchg ax, [bx+si+2] ; exchange with second number
mov [bx+si], ax ; store second number in first
pop ax ; restore old value of ax
ret ; go back to where we came from
bubblesort: push ax ; save old value of ax
push cx ; save old value of cx
push si ; save old value of si
dec cx ; last element not compared
shl cx, 1 ; turn into byte count
mainloop: mov si, 0 ; initialize array index to zero
mov byte [swapflag], 0 ; reset swap flag to no swaps
innerloop: mov ax, [bx+si] ; load number in ax
cmp ax, [bx+si+2] ; compare with next number
jbe noswap ; no swap if already in order
call swap ; swaps two elements
mov byte [swapflag], 1 ; flag that a swap has been done
noswap: add si, 2 ; advance si to next index
cmp si, cx ; are we at last index
jne innerloop ; if not compare next two
cmp byte [swapflag], 1 ; check if a swap has been done
je mainloop ; if yes make another pass
pop si ; restore old value of si
pop cx ; restore old value of cx
pop ax ; restore old value of ax
ret ; go back to where we came from
start: mov bx, [data] ; send start of array in bx
mov cx, 10 ; send count of elements in cx
call bubblesort ; call our subroutine
mov bx, [data2] ; send start of array in bx
mov cx, 20 ; send count of elements in cx
call bubblesort ; call our subroutine again
mov ax, 0x4c00 ; terminate program
int 0x21
ret
--------------------------------------------
je le compile comme suit :
nasm -f elf -g nomprog.asm
gcc -ggdb -o nomprog nomprog.o
et tout va bien;
maintenant je veut l'exécuter , je lance : ./nomprog
il m'affiche : Erreur de segmentation
pourquoi? quels est le problème? aidez moi s'il vous plait .
cs_patatalo
Messages postés1466Date d'inscriptionvendredi 2 janvier 2004StatutModérateurDernière intervention14 février 20142 27 avril 2010 à 07:51
salut,
c'est exactement ce que te dis ghuysmans99, tu tentes de faire tourner un programme MSDOS sous Linux. C'est comme de tenter de faire tourner un programme Linux sous Windows ou un programme Mac sur un intel.
Si tu veux utiliser gdb, tu dois convertir ton programe en 32 bits et pour Linux, ce qui ne sera pas très compliqué étant donné que tu n'as qu'un appel au systeme: programme terminate que tu traduiras par un syscall Linux sys_exit.
l'autre solution consisterait à utiliser debug pour msdos ou n'importe quel autre debugger 16 bits.
cs_ghuysmans99
Messages postés3983Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 27 avril 2010 à 20:00
Tu peux aussi utiliser sous un vrai DOS (ce n'est pas la console Windows) Insight qui est gratuit et open-source pour débugger tes programmes.
---
VB.NET is good ... VB6 is better
Vous n’avez pas trouvé la réponse que vous recherchez ?
tahsgh
Messages postés22Date d'inscriptionjeudi 17 avril 2008StatutMembreDernière intervention15 novembre 2010 28 avril 2010 à 11:41
Salam,
Merci de vos réponces,
Mais je suis obligé de travailler sous Linux(ubuntu 9.10),
est ce qu'il y a une méthode pour adapter ce code sous linux,
Merci