您的位置:首页 > 其它

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

2014-04-26 17:58 204 查看
;
; 判断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 汇编语言