汇编-十六进制输入输出

来源:互联网 发布:美浓烧底标 知乎 编辑:程序博客网 时间:2024/06/05 15:23
data segment  ASCII db 30h,31h,32h,33h,34h,35h   db 36h,37h,38h,39h       ;0~9的ASCII码   db 41h,42h,43h,44h,45h,46h  ;A~F的ASCII码   hex   db 06h,0fh,0eh,08h ;任意设定一个待转换的一位16进制数data endscode segmentmain proc farassume cs:code,ds:datastart:   push ds   xor  ax,ax   push ax   mov ax,data   mov ds,ax   ;-------------    call input   call crlf   call output   mov ax,4c00h   int 21h   ;-------------main endpinput proc near  mov si,0  mov cx,4LP2:  mov ah,01h  int 21h  cmp al,'A'  jb LP3  sub al,07hLP3:  sub al,30h  mov [hex+si],al  inc si  loop LP2  retinput endpoutput proc near   mov bx,offset ASCII  ;BX指向ASCII码表   mov cx,4   mov si,0LP:   mov al,[hex+si]   and al,0fh   xlat   mov dl,al   mov ah,02h   int 21h   inc si   loop LP   retoutput endpcrlf proc near  mov dl,0dh  mov ah,2  int 21h  mov dl,0ah  int 21h  retcrlf endpcode ends  end  start