📄 ad.c
字号:
////////////////FOR 386ex tiao jian bian yi for 8s-20s //ad sample
//#define MU08 1
//#define MU10 1
#define MU12 1
//#define MU14 1
//#define MU16 1
//#define MU18 1
//#define MU20 1
//#define MU22 1
///////////////////
#include <io.h>
#include <dos.h>
#define NO 0x55 //new4u
#define YES 0xaa
extern unsigned char samm,sam_count;
extern int I1[256],I2[256],I3[256],I4[256],I5[256],I6[256],I7[256],I8[256],I9[256],I10[256],I11[256],I12[256],I13[256],I14[256],I15[256],I16[256],I17[256],I18[256],I19[256];
extern int I20[256],I21[256],I22[256],I23[256],I24[256];//22s
extern int Icd[256];//ccdd
extern int kk1,kk2,kk3,kk4,kk5,kk6,kk7,kk8,kk9,kk10,kk11,kk12,kk13,kk14,kk15,kk16,kk17,kk18,kk19,kk20,kk21,kk22,kk23,kk24;
extern int II1,II2,II3,II4,II5,II6,II7,II8,II9,II10,II11,II12,II13,II14,II15,II16,II17,II18,II19,II20,II21,II22;
extern int Id11[256],Ixc2[256],Id[256],If[256];//,U1[256],U2[256];
extern unsigned char aderr;
extern int i_f,i_d;
extern void AD(void);
#define tracept 0x160 /*LF398 Trace -- 1 Level*/
#define adstupt 0x163 /*A/D Status port*/
#define addtpt 0x166 /*A/D data port -- 16 bits*/
#define adstart 0x168 /*Start again to A/D conversion after reading A/D data*/
#define adstupt1 0x162
#define addtpt1 0x164 /*A/D data port -- 16 bits*/
void AD(void){
#ifdef MU12 //12s
asm{
mov al,sam_count;
mov bl,al
mov bh,0;
add bx,bx;
mov samm,al; //xxx
// mov this_sam,al;
inc al;
mov sam_count,al;
mov si,0
mov di,0
}
adst01:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst01;}
asm{
mov dx,addtpt1
in ax,dx; //A/D transfer value of Ua
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov Icd[bx],ax //ccdd
mov cx,kk1 //new15
cmp cx,1
je KK_1
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_1:
asm{ //new15
mov II1,ax
mov I1[bx],ax
}
adst02:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst02;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk2 //new15
cmp cx,1
je KK_2
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_2:
asm{ //new15
mov II2,ax
mov I2[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst03:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst03;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk3 //new15
cmp cx,1
je KK_3
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_3:
asm{ //new15
mov II3,ax
mov I3[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst04:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst04;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk4 //new15
cmp cx,1
je KK_4
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_4:
asm{ //new15
mov II4,ax
mov I4[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst05:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst05;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk5 //new15
cmp cx,1
je KK_5
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_5:
asm{ //new15
mov II5,ax
mov I5[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst06:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst06;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk6 //new15
cmp cx,1
je KK_6
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_6:
asm{ //new15
mov II6,ax
mov I6[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst07:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst07;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk7 //new15
cmp cx,1
je KK_7
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_7:
asm{ //new15
mov II7,ax
mov I7[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst08:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst08;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk8 //new15
cmp cx,1
je KK_8
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_8:
asm{ //new15
mov II8,ax
mov I8[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst09:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst09;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk9 //new15
cmp cx,1
je KK_9
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_9:
asm{ //new15
mov II9,ax
mov I9[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst10:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst10;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk10 //new15
cmp cx,1
je KK_10
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_10:
asm{ //new15
mov II10,ax
mov I10[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst11:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst11;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk11 //new15
cmp cx,1
je KK_11
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_11:
asm{ //new15
mov II11,ax
mov I11[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
adst12:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst12;}
asm{
mov dx,addtpt1
in ax,dx;
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk12 //new15
cmp cx,1
je KK_12
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_12:
asm{ //new15
mov II12,ax
mov I12[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov ax,di;
mov i_f,ax;
mov If[bx],ax;
mov ax,si;
mov Id11[bx],ax
cwd
xor ax,dx;
sub ax,dx;
mov i_d,ax;
mov Id[bx],ax;
}
if(_AX=inpw(adstupt1),_AX=_AX&0x06,_AX!=0) //0x0606-0x06
{
aderr=YES;
}
inp(tracept);
if(_AX=inpw(adstupt1),_AX=_AX&0x06,_AX=_AX^0x06,_AX!=0)//0x0606-0x06
{
aderr=YES;
}
#endif //12s
#ifdef MU14
#endif //14s
#ifdef MU16
asm{
mov al,sam_count;
mov bl,al
mov bh,0;
add bx,bx;
mov samm,al; //xxx
// mov this_sam,al;
inc al;
mov sam_count,al;
mov si,0
mov di,0
}
adst01:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst01;}
asm{
mov dx,addtpt1
in ax,dx; //A/D transfer value of Ua
mov Icd[bx],ax //ccdd
mov cx,kk1 //new15
cmp cx,1
je KK_1
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_1:
asm{ //new15
mov II1,ax
mov I1[bx],ax
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk9 //new15
cmp cx,1
je KK_9
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_9:
asm{ //new15
mov II9,ax
mov I9[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst02:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst02;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk2 //new15
cmp cx,1
je KK_2
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_2:
asm{ //new15
mov II2,ax
mov I2[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk10 //new15
cmp cx,1
je KK_10
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_10:
asm{ //new15
mov II10,ax
mov I10[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst03:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst03;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk3 //new15
cmp cx,1
je KK_3
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_3:
asm{ //new15
mov II3,ax
mov I3[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk11 //new15
cmp cx,1
je KK_11
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_11:
asm{ //new15
mov II11,ax
mov I11[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst04:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst04;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk4 //new15
cmp cx,1
je KK_4
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_4:
asm{ //new15
mov II4,ax
mov I4[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk12 //new15
cmp cx,1
je KK_12
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_12:
asm{ //new15
mov II12,ax
mov I12[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst05:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst05;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk5 //new15
cmp cx,1
je KK_5
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_5:
asm{ //new15
mov II5,ax
mov I5[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk13 //new15
cmp cx,1
je KK_13
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_13:
asm{ //new15
mov II13,ax
mov I13[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst06:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst06;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk6 //new15
cmp cx,1
je KK_6
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_6:
asm{ //new15
mov II6,ax
mov I6[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk14 //new15
cmp cx,1
je KK_14
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_14:
asm{ //new15
mov II14,ax
mov I14[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst07:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst07;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk7 //new15
cmp cx,1
je KK_7
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_7:
asm{ //new15
mov II7,ax
mov I7[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk15 //new15
cmp cx,1
je KK_15
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_15:
asm{ //new15
mov II15,ax
mov I15[bx],ax
add si,ax;
cwd
xor ax,dx;
sub ax,dx;
add di,ax;
}
adst08:
asm{
mov dx,adstupt1;
in al,dx;
test al,0x01;
jnz adst08;}
asm{
mov dx,addtpt1
in ax,dx;
mov cx,kk8 //new15
cmp cx,1
je KK_8
sal ax,1
sal ax,1
sal ax,1
sal ax,1
imul cx
mov ax,dx
}
KK_8:
asm{ //new15
mov II8,ax
mov I8[bx],ax
add si,ax; // instead mov
cwd
xor ax,dx;
sub ax,dx;
add di,ax; // instead mov
}
asm{
mov dx,addtpt
in ax,dx
mov dx,adstart;
mov cx,ax //v40-4u 3 line
in ax,dx
mov ax,cx
mov cx,kk16 //new15
cmp cx,1
je KK_16
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -