判断AL是否为十六进制并将其十进制存入AL

;
; 判断AL是否为十六进制并将其十进制存入AL
; author:  wangguolaing
; date:  revised 4/14

.386
.MODEL FLAT

INCLUDE io.h
includelib Kernel32.lib
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

cr          EQU    0dh  
Lf          EQU    0ah      

.STACK      4096

.DATA
Array    DWORD '3','4','f'
prompt   BYTE  cr,Lf,Lf,'The al is not a hex '
         BYTE  cr,Lf,0
number   BYTE 11 DUP (?)
.CODE
_start:
          mov eax,0
          ;mov al,'2'   ;测试数据
          ;mov al,'6'
          mov al,'C'
          ;mov al,'d'

         cmp al,30h
         jl notwhile
         cmp al,39h
         jle whilelow
         cmp al,41h
         jl notwhile
         cmp al,46h
         jle whilemid
         cmp al,61h
         jl notwhile
         cmp al,66h
         jle whileup
         jmp notwhile
         
whilelow   :
         sub eax,48
         dtoa number,eax
         jmp outal
whilemid   :
         sub al,'A'
         add al,10
         
         jmp outal

whileup    :
         sub al,'a'
         add al,10
         jmp outal

outal      :
         dtoa number,eax
         output number
         jmp quit
notwhile   :
         output prompt

quit:       INVOKE ExitProcess, 0   ; exit with return code 0

PUBLIC _start                       ; make entry point public
            END                     ; end of source code

你可能感兴趣的:(汇编语言,80x86)