Das Programm
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 40 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#include <stdio.h> #include <conio.h> #include <dos.h> #include <stdlib.h> #include <time.h> #define signal printf("\a") int port; int ZA,ZV,ZB,ZSAB,ZE,ZIN,ZINVZ; /* ZA, // Zahl A ZV, // VorZeichen ZB, // Zahl B ZSAB, // Zahlen Summe AB ZE, //zahl Ergebnis ZIN, //INport Zahl ZINVZ;//InPort Zeichen*/ int main(void) { clrscr(); port = peek(0x0040,0x0008); //segment:offset 8 LPT1 An LPT1 gotoxy(1,1);printf("Geben Sie Zahl A ein von 0 bis 9");gotoxy(1,1); zahlA: ZA=getch(); if(ZA>=48 || ZA<=58) { gotoxy(35,13);printf("%d",ZA-=48);gotoxy(1,1); gotoxy(1,1);printf("Geben Sie + oder - ein ");gotoxy(1,1); vorzeichen: ZV=getch(); if(ZV=='+' || ZV=='-') { gotoxy(36,13);printf("%c",ZV);gotoxy(1,1); gotoxy(1,1);printf("Geben Sie Zahl B ein von 0 bis 9");gotoxy(1,1); zahlB: ZB=getch(); if(ZA>='0' || ZA<='9') { gotoxy(37,13);printf("%d=",ZB-=48);gotoxy(1,1); //LPT1 Senden ZA ZV ZB 0..9 +- 0..9 ZSAB=ZA|ZB<<4; outport(port,ZSAB); //Senden A und B if(ZV=='+') ZV=1; else ZV=0; outport(port+2,ZV); gotoxy(20,4); printf("A:%x B:%x ZSAB:%x VZ:%x PORT:%x", ZA,ZB,ZSAB,ZV,port); gotoxy(1,1); //LPT1 Lesen Vorzeichen ZINVZ=inport(port+2); ZINVZ=ZINVZ>>1; //1Bit nach Rechts ZINVZ=ZINVZ^0x1;//invertiere das 1bit if(ZINVZ==0) {gotoxy(39,13);printf("+");gotoxy(1,1);} else {gotoxy(39,13);printf("-");gotoxy(1,1);} delay(100); //LPT1 Lesen 5 Bit Zahl ZIN=inport(port+1); //Bit zusamenzaelen //bit z= 7654 3000 // xxxx x000 ZIN=ZIN^(0x01<<7);//invertiere das 7Bit ZIN=ZIN&0x1F; //Losche die 6Bit und die weiteren ZIN=ZIN>>3; //verschiebe um 3 bit nach rechts gotoxy(40,13);printf("%d",ZIN);gotoxy(1,1); } else {signal; goto zahlB;} } else {signal; goto vorzeichen;} } else {signal; goto zahlA;} gotoxy(1,1);getch(); return 0; } |