[assembleur]programmation

sina -  
 zake_esisa -
bonjour cher amis
je suis un debutant et j'ai chercher comment programmer une carte d'accisition avec 4 sortie et j'ai trouver ce code source j'ai compri un ptit peut les instruction mov ...mais j'arrive pas comprendre tout le programme j'aimerai bien que vous m'aidier avec un organigramme
merci boucoup de votre aide d'avance

Le programme en C intégrant l’assembleur .
#include <math.h>
#include "mex.h"

/* Output Arguments */
#define D_OUT plhs[0]

void adc4(
double data[]
)

{
int voie,voie1,voie2,voie3;
asm {
mov al,0x00
mov dx,0x378
out dx,al
mov al,0x00
mov dx,0x37a
out dx,al
mov al,0x0f
out dx,al
nop
nop
nop
mov al,0x00
out dx,al
mov dx,0x379
lop20:
in al,dx
test al,8
jnz lop20
lop10:
in al,dx
test al,8
jz lop10
mov al,0x00
mov dx,0x37a
out dx,al
nop
and al,0xf0
mov bl,al
mov cl,4
shr bl,cl
mov dx,0x378
mov al,0x01
out dx,al
mov dx,0x379
in al,dx
and al,0xf0
or al,bl
and eax,0x000000ff
mov voie,eax
}
data[0]=voie;
asm
{
mov al,0x10
mov dx,0x378
out dx,al
mov al,0x00
mov dx,0x37a
out dx,al
mov al,0x0f
out dx,al
nop
nop
nop
mov al,0x00
out dx,al
mov dx,0x379
lop21:
in al,dx
test al,8
jnz lop21
lop11:
in al,dx
test al,8
jz lop11
mov al,0x00
mov dx,0x37a
out dx,al
nop
and al,0xf0
mov bl,al
mov cl,4
shr bl,cl
mov dx,0x378
mov al,0x11
out dx,al
mov dx,0x379
in al,dx
and al,0xf0
or al,bl
and eax,0x000000ff
mov voie1,eax
}
data[1]=voie1;
asm
{
mov al,0x08
mov dx,0x378
out dx,al
mov al,0x00
mov dx,0x37a
out dx,al
mov al,0x0f
out dx,al
nop
nop
nop
mov al,0x00
out dx,al
mov dx,0x379
lop22:
in al,dx
test al,8
jnz lop22
lop12:
in al,dx
test al,8
jz lop12
mov al,0x00
mov dx,0x37a
out dx,al
nop
and al,0xf0
mov bl,al
mov cl,4
shr bl,cl
mov dx,0x378
mov al,0x09
out dx,al
mov dx,0x379
in al,dx
and al,0xf0
or al,bl
and eax,0x000000ff
mov voie2,eax
}
data[2]=voie2;
asm
{
mov al,0x18
mov dx,0x378
out dx,al
mov al,0x00
mov dx,0x37a
out dx,al
mov al,0x0f
out dx,al
nop
nop
nop
mov al,0x00
out dx,al
mov dx,0x379
lop23:
in al,dx
test al,8
jnz lop23
lop13:
in al,dx
test al,8
jz lop13
mov al,0x00
mov dx,0x37a
out dx,al
nop
and al,0xf0
mov bl,al
mov cl,4
shr bl,cl
mov dx,0x378
mov al,0x19
out dx,al
mov dx,0x379
in al,dx
and al,0xf0
or al,bl
and eax,0x000000ff
mov voie3,eax
}
data[3]=voie3;
return;
}

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )
{
double *data;
unsigned int m,n;
/* Check for proper number of arguments */
if (nrhs!=0) {
mexErrMsgTxt("ADC809 ne demande pas des arguments en entrée.");
} else if (nlhs>1) {
mexErrMsgTxt("ADC809 a un seul argument en sortie.");
}
m = 4;
n = 1;
/* Create a matrix for the return argument */
D_OUT = mxCreateDoubleMatrix(m, n, mxREAL);

/* Assign pointers to the various parameters */
data = mxGetPr(D_OUT);
/* Do the actual computations in a subroutine */
adc4(data);
return;
}

4 réponses

  1. PHAREL Messages postés 3 Date d'inscription   Statut Membre
     
    salut sina je dois me déconnecté mais voici mon mail écrit moi pour que je puisse t'envoyer l'organigramme j'ai un projet de fin d'étude qui tend vers la programmation des entrées/sorties je pense qu'on pourra beaucoup échanger: ftarnagda2002@yahoo.fr
    bonne continuation et a plus.
    0
  2. Jean-Dom Messages postés 13 Statut Membre 1
     
    . Bonjour,

    Passer du code comme ça dans un forum, faut être optimiste.

    Autant que je me souvienne, MOV est en syntaxe MOV DESTINATION, ORIGINE. Cela donne

    mov al,0x00.......RAZ registre AL
    mov dx,0x378....Init adresse dans DX
    out dx,al............Sortie vers le periphérique à l'adresse 378
    mov al,0x00.......RAZ AL
    mov dx,0x37a....Init adresse DX
    out dx,al............Sortie 0 -> 37a
    mov al,0x0f........0F -> AL
    out dx,al............Sortie 0F -> 37a
    nop...................On attend un peu
    nop
    nop
    mov al,0x00
    out dx,al
    mov dx,0x379
    lop20:................Etiquette
    in al,dx...............Entrée AL <- 379
    test al,8.............Test sur AL (bit 8, valeur 8, je ne sais pas)
    jnz lop20............Si non nul, on boucle.
    lop10:................Idem, dans l'autre sens.
    in al,dx..............On attend la redescente du bit, probablement.
    test al,8
    jz lop10
    mov al,0x00
    mov dx,0x37a
    out dx,al.............0 -> 37A (acquitement I/O, probablement)
    nop
    and al,0xf0.........Louche : AL est censé être nul ! Vérifier si pas
    mov bl,al............ entrée en même temps que sortie.
    mov cl,4.................
    shr bl,cl
    mov dx,0x378
    mov al,0x01
    out dx,al
    mov dx,0x379
    in al,dx
    and al,0xf0
    or al,bl
    and eax,0x000000ff
    mov voie,eax
    }

    . Jean-Dom.
    0
  3. lamia lokchiri
     
    je suis une debutante je veux voire si vous pouvez m'aidez un programme en assembleur qui calcule la taille de la memoire principale
    0
  4. zake_esisa
     
    est ce que tjr en utilise 0x avant l'adresse des ports soit (com) soit(usb) merci
    0