(* programme comment‚ et expliqu‚ dans le livre *) (* LE DESASSEMBLEUR 8086 COLIBRI, publi‚ par *) (* L'INSTITUT PASCAL: *) (* 26 Rue Lamartine, 75009 PARIS *) (* Tel: (1) 42.85.10.82 *) procedure desassemble_ascii(p_adresse_debut, p_adresse_fin: integer); var l_reste, l_quantite_a_imprimer, l_quantite_imprimee: integer; l_octet: byte; l_controle: boolean; l_premiere_ligne: boolean; l_ligne: string80; l_indice: integer; procedure traite_controle; begin if l_ligne<> '' then begin if b_avec_octets_hexadecimaux then begin for l_indice:= l_quantite_imprimee+ 1 to 8 do write(sortie, ' '); write(sortie, ' ', numero_ligne- 2:4, ' '); end; write(sortie, nom_debut_ligne, ' asc ''', l_ligne, ''''); writeln(sortie); if b_avec_octets_hexadecimaux then write(sortie, f_entier_hexadecimal(adresse- 1), ' '); if l_premiere_ligne then begin l_premiere_ligne:= false; nom_debut_ligne:= ' '; end; l_reste:= l_reste- l_quantite_imprimee; l_quantite_imprimee:= 0; end; l_ligne:= f_octet_hexadecimal(l_octet); end; begin adresse:= p_adresse_debut; l_reste:= p_adresse_fin+ 1- p_adresse_debut; nom_debut_ligne:= f_label_debut_ligne(adresse); l_premiere_ligne:= true; while l_reste> 0 do begin writeln(sortie); if b_avec_octets_hexadecimaux then write(sortie, f_entier_hexadecimal(adresse), ' '); l_ligne:= ''; l_quantite_a_imprimer:= l_reste; if l_quantite_a_imprimer> 8 then l_quantite_a_imprimer:= 8; l_controle:= false; l_quantite_imprimee:= 0; repeat lis_octet_suivant(l_octet); l_quantite_imprimee:= l_quantite_imprimee+ 1; if not (l_octet in [32..127]) then begin traite_controle; l_controle:= true; end else l_ligne:= concat(l_ligne, chr(l_octet)); until l_controle or (l_quantite_imprimee>= l_quantite_a_imprimer); if b_avec_octets_hexadecimaux then begin for l_indice:= l_quantite_imprimee+ 1 to 8 do write(sortie, ' '); write(sortie, ' ', numero_ligne:4, ' '); end; if l_controle then write(sortie, nom_debut_ligne, ' hex ', l_ligne) else write(sortie, nom_debut_ligne, ' asc ''', l_ligne, ''''); l_reste:= l_reste- l_quantite_imprimee; if l_premiere_ligne then begin l_premiere_ligne:= false; nom_debut_ligne:= ' '; end; numero_ligne:= numero_ligne+ 1; if b_stop_ecran and (numero_ligne mod 20= 0) then stop; end; writeln(sortie); end; procedure desassemble_hex(p_adresse_debut, p_adresse_fin: integer); var l_reste, l_quantite: integer; l_octet: byte; l_premiere_ligne: boolean; l_indice: integer; l_ligne: string80; begin adresse:= p_adresse_debut; l_reste:= p_adresse_fin+ 1- p_adresse_debut; nom_debut_ligne:= f_label_debut_ligne(adresse); l_premiere_ligne:= true; while l_reste> 0 do begin writeln(sortie); if b_avec_octets_hexadecimaux then write(sortie, f_entier_hexadecimal(adresse), ' '); l_ligne:= ''; l_quantite:= l_reste; if l_quantite> 8 then l_quantite:= 8; for l_indice:= 1 to l_quantite do begin lis_octet_suivant(l_octet); l_ligne:= concat(l_ligne, f_octet_hexadecimal(l_octet)); end; if b_avec_octets_hexadecimaux then begin for l_indice:= l_quantite+1 to 8 do write(sortie, ' '); write(sortie, ' ', numero_ligne:4, ' '); end; write(sortie, nom_debut_ligne, ' hex ', l_ligne); if l_premiere_ligne then begin l_premiere_ligne:= false; nom_debut_ligne:= ' '; end; l_reste:= l_reste- l_quantite; numero_ligne:= numero_ligne+ 1; if b_stop_ecran and (numero_ligne mod 20= 0) then stop; end; writeln(sortie); end;