1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
.model small
.stack 2000h
.data
aff db 'Appuyez sur un caractere pour voir son code ASCII en hexadecimal et en decimal',0dh,0ah, '$'
msg db 0dh,0ah, 'la valeur decimale est: ' ,'$'
msg1 db 0dh,0ah, 'la valeur hexadecimale est: ','$'
fort db ?
faible db ?
lettre db ?
.code
MOV AX, @DATA
MOV DS, AX
;#############MEssage initial############
MOV DX, OFFSET AFF
MOV ah,09H
INT 21H
;**************saisie*******
mov ah,1 ; lecture au clavier du caractere
int 21h ; mettre le caractere dans al
mov lettre ,Al ;on enregistre le caractere
mov dx,offset msg1
mov ah,09H
int 21h
;*****TRAITEMENT************
mov ah, al
mov cx,4
for: shr ah,1 ;apres cette boucle, ah contient les 4 bits de poids fort
mov bh,ah ; on stock dans bh
loop for ; du code ascii
cmp ah, 09h
jle lab1
add ah, 07h
lab1: add ah, 30h
and al, 0fh
mov bl,al ;les 4 bit faible dans bl
cmp al,09h
jle lab2
add al,07h
lab2: add al,30h
;**********affichage*******
mov fort, ah
mov faible, al
mov dl, fort
mov ah, 02h
int 21h
mov dl, faible
mov ah, 02h
int 21h
;######################affichage decimal###################
mov dx,offset msg
mov ah,09H
int 21h
;************traitement2*******************
mov al,lettre
mov ah,0
MOV CL, 10
DIV CL
MOV DH, AH
MOV DL,0
ADD aL, 30H
MOV DL, aL
MOV AH, 2
INT 21H
ADD DH, 30H
MOV DL, DH
MOV AH, 2
INT 21H
;*************fin de programme**************
mov ah,4ch
int 21h
end |
Partager