判断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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值