+ Reply to Thread
Results 1 to 1 of 1

Thread: 24.02.2012 KP (C++)

  1. #1
    All knowing Bloo_uni's Avatar
    Join Date
    Oct 2010
    Posts
    182

    24.02.2012 KP (C++)

    Паралелен интерфейс в PC. LPT порт.
    зад 31/2,4
    зад2.
    Напишете програма на С, която открива инсталираните на дънната платка паралелни портове и извежда адресите им. Изведете константите за time-out от описаните оп-горе служебни клетки от паметта
    Code:
    #include <stdio.h>
    #include <dos.h>
    void main(void){
     int lp;
     char to;
     unsigned int far *ptraddr;  /* Pointer to location of Port Addresses */
     unsigned int far *timeout;
     unsigned int address;       /* Address of Port */
    // unsigned int address2;
     int a;
     ptraddr=(unsigned int far *)0x00000408;
    // timeout=(unsigned int far *)0x00000478;
    
     for (a = 0; a < 4; a++)
       {
        address = *ptraddr;
    //    address2 = *timeout;
        if (address == 0)
       printf("No port found for LPT%d \n",a+1);
        else
       printf("\n Address assigned to LPT%d is %Xh \n",a+1,address);
    
       *ptraddr++;
    
          lp=peek(0,0x408+a+a);
           if(lp)
           printf(" LPT%d=%x, to=%x\n",a+1, lp, peekb(0,0x478+a) );
        else
       printf("LPT$d not installed", a+1);
    
    
       }
    
    //    int peek(int seg, int offs);
    //    char peekb(int seg, int offs);
     }
    Code:
     Address assigned to LPT1 is 3BCh
     LPT1=3bc, to=14
    
     Address assigned to LPT2 is 378h
     LPT2=378, to=14
    
     Address assigned to LPT3 is 278h
     LPT3=278, to=14
    
     Address assigned to LPT4 is 9FC0h
     LPT4=9fc0, to=14
    
    C:\DOCUME~1\CP>debug
    -d 0:408
    0000:0400                          BC 03 78 03 78 02 C0 9F           ..x.x...
    0000:0410  23 C8 00 80 02 00 00 20-00 00 2E 00 2E 00 64 20   #...... ......d
    0000:0420  20 39 30 0B 3A 27 34 05-30 0B 38 09 0D 1C 00 00    90.:'4.0.8.....
    0000:0430  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
    0000:0440  BA 00 C3 00 00 00 00 00-00 03 50 00 00 10 00 00   ..........P.....
    0000:0450  00 16 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
    0000:0460  0F 0C 00 D4 03 29 30 C5-93 FF FF 00 3A 47 0C 00   .....)0.....:G..
    0000:0470  00 00 00 12 00 00 00 00-14 14 14 14 01 01 01 01   ................
    0000:0480  1E 00 3E 00 18 10 00 60                           ..>....`
    -
    Last edited by Bloo_uni; 24-02-2012 at 12:33 PM.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts