Guest User

screen.asm

a guest
Nov 7th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;**** DATA ***
  2. cpt: db 0
  3. xpos: db 0
  4.  
  5. print:
  6.     MOV byte [cpt], 0
  7. .aff:
  8.     MOV DL,[ESI]
  9.     CMP DL, 10
  10.     JNE .continue
  11.     CALL enter
  12.     JMP .fin
  13. .continue
  14.     CMP DL,0
  15.     JE  .fin
  16.     call putchar
  17.     INC ESI
  18.     INC byte [cpt]
  19.     JMP .aff
  20. .fin:
  21.     MOV EAX, [cpt]
  22.     RET
  23.  
  24. print80:
  25.     MOV byte [cpt], 0
  26. .aff:
  27.     MOV DL,[ESI]
  28.  
  29.     CMP DL, 10
  30.     JNE .continue
  31.     CALL enter
  32.     JMP .fin
  33. .continue
  34.  
  35.     CMP DL,0
  36.     JE  .fin
  37.     CMP ECX, 0
  38.     JE .fin
  39.     DEC ECX
  40.     call putchar
  41.     INC ESI
  42.     INC byte [cpt]
  43.     JMP .aff
  44. .fin:
  45.     MOV EAX, [cpt]
  46.     RET
  47.    
  48. putchar:
  49.     pusha
  50.    
  51.     xor eax,eax         ; Mise à 0 de EAX
  52.     mov byte al,[xpos]      ; On place dans AL la position de X que
  53.     mov bl,2            ; l'on multiplie par 2 car le caractère est
  54.     mul bl              ; sur le 1er byte, la couleur sur le 2ème
  55.     add eax,0xB8000+80*2*24     ; On ajoute B8000(mémoire vidéo) et la ligne 24 de l'écran
  56.     mov edi,eax
  57.     MOV DH,0x0F
  58.    
  59.     MOV [EDI],DX        ; On place le caractère lu dans EDI
  60.     call decalx
  61.    
  62.     popa
  63.    
  64.     RET
  65.  
  66. enter:
  67.     MOV byte [xpos], 79
  68.     call scrollup
  69.     MOV byte [xpos], 0
  70.  
  71.     RET
  72.    
  73. scrollup:
  74.     MOV ESI,0xB8000+80*2
  75.     MOV EDI,0xB8000
  76.     MOV ECX,0xFA0-80*2
  77.     REP MOVSB
  78.    
  79.     MOV al,0x0
  80.     MOV EDI,0xB8FA0-80*2
  81.     MOV ECX,80*2
  82.     REP STOSB
  83.  
  84.     RET
  85.  
  86. clear:
  87.     MOV al,0x0
  88.     MOV EDI,0xB8000
  89.     MOV ECX,0xFA0
  90.     REP STOSB
  91.     RET
  92.    
  93. back:
  94.     call decalxg
  95.     mov dl,' '
  96.     call putchar
  97.     call decalxg
  98.     RET
  99.    
  100. decalx:
  101.     cmp byte [xpos],79
  102.     JNZ .decalun
  103.    
  104.     call scrollup
  105.     mov byte [xpos],0
  106.     jmp .endecal
  107. .decalun:
  108.     inc byte [xpos]
  109. .endecal:
  110.     RET
  111.  
  112.    
  113.  
  114. decalxg:
  115.     cmp byte [xpos],0
  116.     JNZ .decalun
  117.    
  118.     call scrollup
  119.     mov byte [xpos],79
  120.     jmp .endecal
  121. .decalun:
  122.     dec byte [xpos]
  123. .endecal:
  124.     RET
  125.  
  126.  
Advertisement
Add Comment
Please, Sign In to add comment