Кресты / Говнокод #10187 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
#/*        */include<stdio.h>
                    /*    */int/**/main(int/**/o,char**O){int      y[4],
                  r[4]   ,z[4],C,h,i,n,a,t,s,u[2][3][4]={{{6,9,0,3}     ,
                {     1,10,4,7},{5,11,2,8}},{{3,0,6,9},{10,1,4,7},{     8,2,5
          ,11}}},    M,I,R,A,K,U[2],RU[2],N[2],_=2;FILE*x[03]      ;  unsigned/*,
       */char/**/ p[2][3<<16],d[12],b[256][256];float/**/f,q        [12];if((o<4)){
      return!puts("<a.ppm>\40<b.ppm>\40<output.ppm>\40[odd]")    ;}else{for(h=0;h<2;
    h++){M=SEEK_SET;if(!(x[h]=fopen(O[h+1],"rb")))goto/**/e;if( (int)fread(*b,1,256,x[h
    ])<1||sscanf((char*)*b,*O="P6\n%d\40%d\n%d\n",&U[h],&N[h],&i)-3||i-255)goto/**/e;for(
   i=C=RU[h]=0;i<256&&!RU[h];i++)if(b[0][i]=='\n')if(++C==3)fseek(x[h],RU[h]=i+1,M);if(!RU
  [h]||U[h]<1||U[h]>(1<<16))goto/**/e;}if(*U-U[1]||*N-N[1])goto/**/s;for(h=0;h<256;h++)for(
  i=0;i<256;b[h][i++]=0) ;for(i=0;i<*N;i++){for(h=0;h<2;h++)if(fread(p[h],3**U,01,x[h])!=1)
 goto/**/e;for(h=0;h<3**  U;h++)b[p[0][h]][p[1][h]]=1; }*y=*r=y[2]=r[2]=64;y[1]=r[1]=y[3]=r[
 3]=192;A=(y[1]-*y)*(y[   3]-y[2]);for(M=64;M>0; M/=2) {for(t=-1;t<=0;t++)if((*z=*r+t*M)>-1)
 for(I=-1;I<1;I++)if((z    [ 2]=r[2]+I*M)> (-1))  for   (s=1;s>-1;s--)if((z[1]=r[1]+s*M)<257
 )for(R=1;R>-1;R--)if(     +  257>(z[3]=r  [3]+R*  M)   )if((K=(z[1]-z[0])*(z[3]-z[2]))>A){
for(h=C=0;h<256&&C> -1           &&C<256;   h  ++)for      (n=h*(z[1]-z[i=0])/256+*z;C>-1&&
i<256&&C<256;i++){a =  i*(z[3]-z              [2    ])/256+ z[2];if(b[h][i])C=(3*n-a)/2;}if
 (C>-1&&C<256)for(C  =0     ,   A=           K  ;C   <4;++   C)y[C]=z[C];}for(C=0;C<4;C++)r
 [C]=y[C];}if(!(x[2     ]   =/*                 */   fopen   (O[03],"wb+")))goto/**/e;else{
 fprintf(x[2],*O,2*    *U,2**N,+               255);for(h=   0;h<(2);h++)fseek(x[h],RU[h],
 SEEK_SET);C=(o<5)?    1/***/:00               ;/***/R=1+(  1<<16);for(i=0;i<*N;i++){for(h
 =0;h<2;h++)if(fread   (/****/p[               h/****/],+3  **U,1,x[h])!=1)goto/**/e;for(
  M=0;M<7;M+=6)for(h    =/**/0;*                U/**/>h;h  ++){for(n=0;n<3;n++){for(a=0;
   a<2;a++)q[u[C][n]     [a]]=p                  [a][h    *3+n]*(r[a*2+1]-r[a*2])/256.f
   +r[a*2];q[u[C][n]                                     [2]]=q[u[C][n][3]]=(3*q[*u[C][
    n]]-q[u[C][n][1]]                                    )/2;}for(n=0;n<12;d[n++]=t<0?
    0:(t>255?255:t)){               t       =          q[n];f=q[n]-t;_=(_*75)%R;if(_<f
     *R)++ t;}fwrite(d               +M,6,1,            x[2]);}}}}for(h=0;h<3;h =h + 1
     )  t=   fclose(x [h                               ]);     return  (t*1);s  :
         *O    ="si"    /*                           */       "ze ";   printf  (
           *     /*'      P*/                     O);        ;e  :    return
                  !          /*w*/            puts                      /*;
                                  */("error");                            }

http://uguu.org/sources.html юзайте ребята.

Запостил: KusokGovna KusokGovna, (Updated )

Комментарии (11) RSS

      • Кстати, давно я не смотрел этот конкурс. В этом году (2018) Фабрис Беллард представил алгоритм бесконечного зожатия и разжатия Лены:
        http://ioccc.org/2018/bellard/
        Ответить
      • http://ioccc.org/2018/mills/

        Эмулятор PDP-7.

        The [PDP-7] [10] is an odd duck by modern computer standards:
        
          * 18 bit words, with no byte addressing.
          * Both one's and two's complement math (there is `ADD` for one's complement
             and `TAD` for two's complement).  The EAE is entirely one's-complement.
          * "Microcoded" instructions.
          * Auto-increment memory locations.
          * Non-reentrant function calls (the return address is stored at the indicated
            address and the PC jumps to the location after it).
          * The `XCT` instruction, that executes the word loaded from memory as an
            instruction.
          * An instruction `LAW` that loads the instruction opcode into the
            accumulator.
          * Heavy use of "inline" operands.  For instance the `MUL` instruction expects
            the second operand to be stored in memory after the instruction.  This
            pretty much requires the use of self-modifying code.
          * No immediates.  Almost all constants have to live in memory locations and
            be referenced by address.
          * Common operations, like "subtract" and "inclusive OR" are not directly
            supported on the machine and require multiple instructions and some spare
            memory locations to support.  Being clever also helps.
          * Single accumulator architecture.  No direct support for things like stacks.
          * I/O is done with dedicated I/O instructions (which are also microcoded).
          * The RB09 disk controller gets a special mention here because of its
            particularly annoying encoding of track and sector offsets in
            [packed BCD] [11].  A non-trivial amount of code space in the simulator
            is needed to convert into and out of BCD, along with an equivalent amount
            of code in the UNIX kernel itself.
        Ответить
        • >>Эмулятор PDP-7.
          а там пойдет "космическое путешествие" або что там хлопци написали чтобы натренироваться перед юниксом?
          Ответить
          • Надо проверять. В remarks.markdown нашёл следующее:
            The program delivered here is both a full machine emulation of the original
            PDP-7 that Ken Thompson used to write the first version of UNIX and a full
            machine emulation of the PDP-11/40 used by subsequent UNIXes.  The `Makefile`
            can build versions that can run each of the following:
            
              1. UNIX v0 for the PDP-7 (circa 1969)
              2. Research UNIX Version 6 (circa 1975)
              3. BSD 2.9 (circa 1983)

            ...
            The emulator emulates the full machine:
            
              * PDP-7 Central Processor
              * Core Memeory Module Type 147 -- extends the core to 8,192 18-bit words
              * Extended Arithmetic Element Type 177 -- adds one's-complement
                multiplication, division and shifting
              * Real Time Clock
              * Teletype Model 33 KSR
              * Perforated Tape Reader Type 444
              * RB09 Fixed Disk Controller
            Ответить
            • The simulation handles everything I was able to discover about the PDP-7, even
              things that the UNIX code itself doesn't use.  For instance, it correctly
              implements the "trap mode" feature (a primitive form of supervisor mode) even
              though the kernel does not enable it.  It also implements the microcoding of
              the EAE instructions even though the UNIX environment uses only the standard
              encodings.  If you wanted to do a 11-bit multiply instead of an 18-bit one,
              it will probably work.
              Ответить
              • И на десерт самое вкусное:

                So if I have a PDP-7 emulator, how do I run operating systems that expect a
                PDP-11?  Simple...  *I emulate a PDP-11/40 on the PDP-7*.  I have written
                PDP-7 assembler code to emulate a PDP-11/40 with the following equipment:
                
                  * PDP-11/40 (KD11-A)
                  * EIS instruction set (KE11-E)
                  * Memory management unit (KJ11-A)
                  * Line time clock (KT11-D)
                  * 124 Kwords of memory (244 Kbytes)
                  * RK05 fixed disk drive (RK11)
                  * Console TTY (DL11)
                Ответить

Добавить комментарий

Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:

    А не использовать ли нам bbcode?


    8