Guida all'assembler



Partiamo con il codice del programma
                  ;segmento disco   9:0000
;00,08,05,00  segmento impostazioni
;00,08,05,80  segmento codice
;23:0000      segmento di copia
;24:0000      buffer del disco
      jmp 0000
*00           ;0003
*00 00 00 00  ;0004 carattere
*00 00 24 00  ;0008 inizio copia
*00 00 23 00  ;000c fondo copia
*00           ;0010 contatore
:0001 push esi ;imposta la pagina***************
      push edi
      push ebx
      push cx
      mov bx,030F        ;colore
      xor eax,eax
      mov ax,[00130006]
      callf 0008:002A
      mov esi,edi
      mov edi,[00010248]
      mov eax,[00010240]
      shl eax,02
      add eax,00000040
      add edi,eax
      mov cx,0004
:0002 mov al,[esi]
      callf 0008:0016
      add edi,00000008
      inc si
      loop 0002
      pop cx
      pop ebx
      pop edi
      pop esi
      ret
:0003 push ecx ;imposta inizio pagina*****************
      push edx
      lea ebp,00240000
      mov ax,[00130006]
      dec ax
      shl ax,09
      mov bp,ax
      mov edi,[00010248]
      mov eax,[00010240]
      mov ecx,00000018
      mul ecx
      add edi,eax
      pop edx
      pop ecx
      ret
:0004 push esi ;spampa una pagina**************
      push edi
      push ebp
      push dx
      mov bx,0009        ;colore
      lea esi,00101380
      mov dx,0020        ;ciclo in verticale
:0007 push edi
      mov [00090010],10  ;ciclo in orizzontale
:0006 lea si,1380
      mov [esi],39
      inc si
      mov cx,0001
      mov al,[ebp+00]
      callf 0008:001C
      mov [esi],39
      lea si,1380
      mov cx,0004
:0005 mov al,[esi]
      callf 0008:0016
      inc si
      add edi,00000008
      loop 0005
      inc bp
      dec [00090010]
      jnz 0006
      pop edi
      mov eax,[00010240]
      shl eax,04
      add edi,eax
      dec dx
      jnz 0007
      lea esi,000A0000
      mov cx,0040        ;pulisce la pagina
:000a push edi
      push cx
      mov si,di
      callf 0008:0015
      mov cx,0080
      xor eax,eax
:0009 mov [esi],eax
      add si,0004
      jnz 0008
      add edi,00010000
      callf 0008:0015
:0008 loop 0009
      pop cx
      pop edi
      add edi,[00010240]
      loop 000A
      pop dx
      pop ebp
      pop edi
      pop esi
      ret
:000b push ecx ;punto inserimento************
      push edx
      push dx
      mov edi,[00010248]
      mov eax,[00010240]
      mov ecx,00000018
      mov dh,00
      shl dx,04
      add cx,dx
      mul ecx
      add edi,eax
      xor eax,eax
      pop ax
      shr ax,08
      mov cx,0020
      mul cx
      add ax,0008
      add edi,eax
      pop edx
      pop ecx
      ret
:000c push ebp ;modo cursore********************
      push cx
      call 000B
      callf 0008:0015
      lea ebp,000A0000
      mov bp,di
      mov cx,0010        ;punti in verticale
:0010 push cx
      mov cx,0004        ;punti in orizzontale
:000e xor [ebp+00],04040404
      add bp,0004
      jnz 000D
      add edi,00010000
      callf 0008:0015
:000d loop 000E
      mov ax,[00010240]
      sub ax,0010
      add bp,ax
      ja 000F
      add edi,00010000
      callf 0008:0015
:000f pop cx
      loop 0010
      pop cx
      pop ebp
      ret
:0011 push esi ;segmento numero***************
      callf 0008:0091
      lea esi,00101719
      callf 0008:007E
      lea esi,00101380
      mov eax,[00130020]
      mov cx,0004
      callf 0008:001C
      mov [esi],00
      lea si,1380
      callf 0008:007E
      pop esi
      ret
:0012 push esi ;coordinate******************
      push edi
      push ebx
      push cx
      push dx
      mov bx,030F        ;colore
      lea esi,00101380
      mov ax,[00130006]
      dec ax
      shl ax,09
      mov cx,dx
      mov ch,00
      shl cx,04
      shr dx,08
      add ax,cx
      add ax,dx
      mov cx,0002
      callf 0008:001C
      lea si,1380
      mov edi,[00010248]
      mov eax,[00010240]
      shl eax,02
      add eax,000002A8
      add edi,eax
      mov cx,0004
:0013 mov al,[esi]
      callf 0008:0016
      add edi,00000008
      inc si
      loop 0013
      pop dx
      pop cx
      pop ebx
      pop edi
      pop esi
      ret
:0014 push ebx ;nuovo segmento****************
      lea ebx,00101500
      xor eax,eax
:0016 mov bl,[esi]
      cmp bl,A8
      jz 0015
      shl eax,04
      mov bl,[ebx]
      add al,bl
      inc si
      jmp 0016
:0015 mov [00130020],eax
      mov ax,0000
      mov [00130028],ax
      pop ebx
      ret
:0017 push esi ;copia il codice*******************
      push edi
      cmp [00090003],00
      jz 0018
      mov esi,[00090008]
      lea edi,00230000
:001a mov al,[esi]
      mov [edi],al
      cmp si,bp
      jz 0019
      inc si
      inc di
      jmp 001A
:0019 inc di
      mov [0009000C],di
:0018 pop edi
      pop esi
      ret
:001b push esi ;sposta il codice*****************
      push edi
      cmp [00090003],01
      jz 001C
      lea esi,00230000
      mov edi,ebp
:001d cmp si,[0009000C]
      jz 001C
      mov al,[esi]
      mov [edi],al
      inc si
      inc di
      jmp 001D
:001c pop edi
      pop esi
      ret
jmpf 0008:001E
:0000 mov ax,0080        ;inizio codice**********************
      mov [00010214],ax
      mov eax,[00130020]
      mov [00010218],eax
      mov eax,00240000
      mov [0001021C],eax
      callf 0008:000D    ;carica il buffer
:010b mov dx,0000
      call 0001          ;imposta la pagina
      call 0012          ;coordinate
      call 0003          ;imposta inizio pagina
      call 0004          ;stampa la pagina
      call 000C          ;disegna il cursore
      call 0011          ;segmento numero
:0101 mov ax,[00010210]  ;ciclo tastiera+++++++++++++++++++
      cmp al,00
      jz 0101
      mov [00010210],0000
      cmp ax,E02A
      jz 0101
      cmp ax,E04D
      jz 0102
      cmp ax,E04B
      jz 0103
      cmp ax,E050
      jz 0104
      cmp ax,E048
      jz 0105
      cmp ax,E051
      jz 0106
      cmp ax,E049
      jz 0107
      cmp ax,E037
      jz 0108
      cmp ah,E0
      jz 0101
      cmp al,3B
      jz 0100
      cmp al,01
      jz 0109
      mov [00090004],al  ;carattere++++++++++++++++
      lea ebx,00101500
      mov bl,al
      mov al,[ebx]
      cmp al,FF
      jz 0101
      mov [00090005],al
      call 000B
      mov bx,0009        ;colore
      mov al,[00090004]
      callf 0008:0016
      add edi,00000008
:010A mov ax,[00010210]  ;ciclo tastiera
      cmp al,00
      jz 010A
      mov [00010210],0000
      cmp ax,E02A
      jz 010A
      cmp ah,E0
      jz 010A
      mov [00090006],al  ;secondo carattere
      lea ebx,00101500
      mov bl,al
      mov al,[ebx]
      cmp al,FF
      jz 010A
      mov [00090007],al
      mov bx,0009
      mov al,[00090006]
      callf 0008:0016
      mov al,[00090005]
      shl al,04
      add al,[00090007]
      mov [ebp+00],al
      call 000C
:0102 cmp dh,0F          ;cursore a destra
      jz 0101
      call 000C
      inc dh
      inc bp
      call 0012
      call 000C
      jmp 0101
:0103 cmp dh,00          ;cursore a sinistra
      jz 0101
      call 000C
      dec dh
      dec bp
      call 0012
      call 000C
      jmp 0101
:0104 cmp dl,1F          ;cursore in basso
      jz 0101
      call 000C
      inc dl
      add bp,0010
      call 0012
      call 000C
      jmp 0101
:0105 cmp dl,00          ;cursore in alto
      jz 0101
      call 000C
      dec dl
      sub bp,0010
      call 0012
      call 000C
      jmp 0101
:0106 mov ax,[00130006]  ;pagina in gił
      cmp ax,0080
      jz 0101
      inc ax
      mov [00130006],ax
      jmp 010B
:0107 mov ax,[00130006]  ;pagina in sł
      cmp ax,0001
      jz 0101
      dec ax
      mov [00130006],ax
      jmp 010B
:0109 mov ax,0080        ;salva il segmento codice
      mov [00010214],ax
      mov eax,[00130020]
      mov [00010218],eax
      mov eax,00240000
      mov [0001021C],eax
      callf 0008:0096
      jmp 0100
:0108 callf 0008:0091    ;linea di comando+++++++++++++
      callf 0008:0081
      lea esi,001013C0
      cmp [esi],21
      jz 010C
      cmp [esi],17
      jz 010D
      inc si             ;c++++++++++++
      cmp [esi],18
      jz 010E
      inc si
      cmp [esi],32
      jnz 0108
      inc si
      inc si
      inc si
      inc si
      lea esi,00101719   ;cambia segmento
      callf 0008:007E
      mov esi,[0001022C]
      callf 0008:0081
      call 0014
      jmp 0000
:010e inc si
      cmp [esi],19
      jnz 0108
      inc si
      inc si
      inc si
      mov [00090008],bp  ;copia
      mov [00090003],01
      jmp 0101
:010c inc si             ;f++++++++++++
      cmp [esi],17
      jnz 0108
      inc si
      inc si
      inc si
      call 0017          ;fine
      mov [00090003],00
      jmp 0101
:010d inc si             ;i++++++++++++
      cmp [esi],31
      jnz 0108
      inc si
      cmp [esi],2E
      jnz 0108
      inc si
      inc si
      inc si
      inc si
      inc si
      call 001B          ;incolla
      jmp 010B
:0100
jmpf 0008:001e
      


Introduzione alla programmazione in "Assembler"
invia E-mail