Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1671 connectés 

  FORUM HardWare.fr
  Programmation
  ASM

  Optimisation... de taille !

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Optimisation... de taille !

n°1152715
Gillian Se​ed
Posté le 18-07-2005 à 16:34:34  profilanswer
 

Voili voilou, il s'agit de rendre plus petit un programme en assembleur qui a déjà été optimisé fortement par moi et un pote (enfin nous pensons qu'il l'est pas mal en tout cas)
 
Voici le programme :
 

Code :
  1. .model tiny
  2. .code                         
  3. .startup
  4.          dd 1fa00068h               
  5.          dw 071eh
  6.          mov al,13h
  7.          int 10h     
  8.          mov di,319
  9.          mov cl,200
  10. drwbrd:  mov ax,1112h 
  11.          stosw
  12.          add di,318
  13.          loop drwbrd
  14.          mov di,7*320+24   
  15.          mov bl,5
  16. Disp:    mov dl,7
  17. Disp_2:  mov al,dl
  18.          add al,40
  19.          mov dh,9
  20. Disp_3:  mov byte ptr [di],42
  21.          mov cl,14
  22.  inc di
  23.          rep stosb
  24.  mov byte ptr [di],42
  25.          add di,17
  26.          dec dh
  27.          jne Disp_3
  28.          add di,32
  29.          dec dx
  30.          jne Disp_2
  31.          add di,6*320
  32.          dec bx
  33.          jne Disp
  34.          mov si,320*196+210-16 
  35.      
  36.          mov bx,si
  37.          mov bp,-319
  38. BigLoop: mov dx,3DAh                 
  39. WR_1:    in al,dx
  40.          and al,8
  41.          jne WR_1
  42. WR_2:    in al,dx
  43.          and al,8
  44.          je WR_2
  45.  dd 417a064h
  46.          sar al,1 
  47.          adc si,cx
  48.          sar al,1 
  49.          sbb si,cx
  50.    
  51.          mov [si-1],cl
  52.  mov di,si
  53.          mov al,1
  54.          mov cl,32
  55.          rep stosb
  56.          xor ax,ax
  57.          stosb
  58.          cmp si,320*196+3
  59.          adc si,cx 
  60.      
  61.          cmp si,320*196+286           
  62.          jb Noprob
  63.          dec si
  64. Noprob:  mov [bx],al 
  65.          add bx,bp
  66.          mov al,13
  67.          mov [bx],al
  68.          mov di,bx                   
  69.          add di,bp
  70.          mov al,[di]
  71.          cmp al,11h   
  72.          jne RSide           
  73.          inc bp
  74.          inc bp
  75. RSide:   cmp al,12h   
  76.          jne Above
  77.          dec bp
  78.          dec bp
  79. Above:   cmp di,320
  80.          ja Dooh
  81.  add bp,640
  82. Dooh:    cmp al,1
  83.          jne Brick
  84.  sub bp,640
  85. Brick:   test al,32                 
  86.          je pasbrik                 
  87.  cmp al,47
  88.          jne pas47
  89.  sub bp,640
  90.  jmp erasebrick
  91. pas47:   cmp al,41
  92.          jne pas41
  93.  add bp,640       
  94.  jmp erasebrick
  95. pas41:   mov ax,320
  96.          or bp,bp
  97.  js onmonte
  98.  neg ax
  99. onmonte: mov dx,bp
  100.  add dx,ax
  101.  sal dx,1
  102.  sub bp,dx
  103. erasebrick:
  104.          sub di,1936                 
  105.  xor ax,ax
  106.          mov dx,13
  107. pasfini: mov cl,16
  108.          rep stosw
  109.          add di,288
  110.          dec dx
  111.          jnz pasfini
  112. pasbrik: cmp bx,320*197             
  113.          ja Bye
  114.  jmp BigLoop
  115. Bye:     mov al,3
  116.          int 10h
  117.          ret                     
  118. end


 
(A compiler avec tasm)
Le but étant bien sûr de ne pas rendre ce petit jeu plus laid qu'il ne l'est (garder la couleur des briques par exemple)
On peut éventuellement modifier la longueur de la raquette ou les touches...
 
Avis aux amateurs  :sol:
 
EDIT: Oh, j'allais oublier : Taille minimum pour l'instant : 250 octets


Message édité par Gillian Seed le 18-07-2005 à 16:35:22
mood
Publicité
Posté le 18-07-2005 à 16:34:34  profilanswer
 

n°1180264
cgsyannick
L 99 99 99 99 99 99 99 99 99
Posté le 20-08-2005 à 17:38:03  profilanswer
 

248 octets :D
 

Code :
  1. .model tiny
  2. .code                         
  3. .startup
  4.          dd 1fa00068h               
  5.          dw 071eh
  6.          mov al,13h
  7.          int 10h     
  8.          mov di,319
  9.          mov cl,200
  10. drwbrd:  mov ax,1112h 
  11.          stosw
  12.          add di,318
  13.          loop drwbrd
  14.          mov di,7*320+24   
  15.          mov bl,5
  16. Disp:    mov dl,7
  17. Disp_2:  mov al,dl
  18.          add al,40
  19.          mov dh,9
  20. Disp_3:  mov byte ptr [di],42
  21.          mov cl,14
  22.  inc di
  23.          rep stosb
  24.  mov byte ptr [di],42
  25.          add di,17
  26.          dec dh
  27.          jne Disp_3
  28.          add di,32
  29.          dec dx
  30.          jne Disp_2
  31.          add di,6*320
  32.          dec bx
  33.          jne Disp
  34.          mov si,320*196+210-16 
  35.      
  36.          mov bx,si
  37.          mov bp,-319
  38. BigLoop: mov dx,3DAh                 
  39. WR_1:    in al,dx
  40.          and al,8
  41.          jne WR_1
  42. WR_2:    in al,dx
  43.          and al,8
  44.          je WR_2
  45.  dd 417a064h
  46.          sar al,1 
  47.          adc si,cx
  48.          sar al,1 
  49.          sbb si,cx
  50.    
  51.          mov [si-1],cl
  52.  mov di,si
  53.          mov al,1
  54.          mov cl,32
  55.          rep stosb
  56.          xor ax,ax
  57.          stosb
  58.          cmp si,320*196+3
  59.          adc si,cx 
  60.      
  61.          cmp si,320*196+286           
  62.          jb Noprob
  63.          dec si
  64. Noprob:  mov [bx],al 
  65.          add bx,bp
  66.          mov al,13
  67.          mov [bx],al
  68.          mov di,bx                   
  69.          add di,bp
  70.          mov al,[di]
  71.          cmp al,11h   
  72.          jne RSide           
  73.          inc bp
  74.          inc bp
  75. RSide:   cmp al,12h   
  76.          jne Above
  77.          dec bp
  78.          dec bp
  79. Above:   cmp di,320
  80.          ja Dooh
  81.  add bp,640
  82. Dooh:    cmp al,1
  83.          jne Brick
  84.  sub bp,640
  85. Brick:   test al,32                 
  86.          je pasbrik                 
  87.  cmp al,47
  88.          jne pas47
  89.  sub bp,640
  90.  jmp short erasebrick
  91. pas47:   cmp al,41
  92.          jne pas41
  93.  add bp,640       
  94.  jmp short erasebrick
  95. pas41:   mov ax,320
  96.          or bp,bp
  97.  js onmonte
  98.  neg ax
  99. onmonte: mov dx,bp
  100.  add dx,ax
  101.  sal dx,1
  102.  sub bp,dx
  103. erasebrick:
  104.          sub di,1936                 
  105.  xor ax,ax
  106.          mov dx,13
  107. pasfini: mov cl,16
  108.          rep stosw
  109.          add di,288
  110.          dec dx
  111.          jnz pasfini
  112. pasbrik: cmp bx,320*197             
  113.          ja Bye
  114.  jmp BigLoop
  115. Bye:     mov al,3
  116.          int 10h
  117.          ret                     
  118. end


 
 [:neodam]


---------------
Découvre le HFRcoin - Afin d’écourter votre attente, merci de bien vouloir patienter…
n°1181419
Gillian Se​ed
Posté le 22-08-2005 à 17:21:59  profilanswer
 

:lol:  
Bien vu ;)

n°1181535
cgsyannick
L 99 99 99 99 99 99 99 99 99
Posté le 22-08-2005 à 19:25:51  profilanswer
 

;)
 
Bon forcement, on gagne pas grand chose hein :o
Et après, mes connaissances sont hélas trop limitée pour t'aider plus en profondeur :/


---------------
Découvre le HFRcoin - Afin d’écourter votre attente, merci de bien vouloir patienter…

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  ASM

  Optimisation... de taille !

 

Sujets relatifs
Optimisation d'une boucle.Optimisation dans une boucle ...
taille d'image[SESSION] taille limite et performance.
pb taille caractères html <form> <input>[Résolu] [C#] Déclaration de tableaux d'objets à taille inconnue
Ajuster la taille d'un userformAdapter le mapping à la taille de l'écran
QUel navigateur pour lire des fichiers html de tres grande taille ?Création dynamique d'un tableau de taille non fixée
Plus de sujets relatifs à : Optimisation... de taille !


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR