如何检查数字是否代表 NASM 程序集中的大写字符? [英] How to check if a number represents an uppercase character in NASM Assembly?

查看:15
本文介绍了如何检查数字是否代表 NASM 程序集中的大写字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您在 EAX 中存储了一个数字.如何检查这个数字是否代表大写字符?

Suppose that you have a number stored in EAX. How can I check whether this number represents an uppercase character or not?

坦率地说,我什么都没试过.我最接近的想法是创建一个大写字符数组 ('A','B','C,'D',...) 然后检查 EAX 是否等于 any这些.在 NASM Assembly 中有没有更简单的方法来做到这一点?

Frankly, I haven't tried anything. The closest idea I had was to create an array of upper case characters ('A','B','C,'D',...) and then check if EAX was equal to any of these. Is there a simpler way to do this in NASM Assembly?

对于 32 位程序,我使用的是 64 位 CentOS.

I'm using 64-bit CentOS, for a 32-bit program.

推荐答案

对于 ASCII 字符,类似这样的方法是可行的:

For ASCII characters, something like this would work:

cmp eax,'A'
setnc bl    ; bl = (eax >= 'A') ? 1 : 0
cmp eax,'Z'+1
setc bh     ; bh = (eax <= 'Z') ? 1 : 0
and bl,bh   ; bl = (eax >= 'A' && eax <= 'Z')
; bl now contains 1 if eax contains an uppercase letter, and 0 otherwise

这篇关于如何检查数字是否代表 NASM 程序集中的大写字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆