英特尔8086大会转换小写字母大写。如果已经处于大写DO_NOTHING并继续保存 [英] Converting Lower Case to Upper case in Intel 8086 Assembly. If Already in Upper Case DO_NOTHING and continue SAVING

查看:422
本文介绍了英特尔8086大会转换小写字母大写。如果已经处于大写DO_NOTHING并继续保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造了这个计划(英特尔8086大会),以读取字符,并将其储存和打印;它们转换为大写后按相反的顺序它们。我知道你可以转换为大写;使用情况(分AL,20H),但我怎么把条件(IF)环

 组织100H
MOV BX,0800H
MOV DS,BX;设置段寄存器
MOV BX,0000H;设置失调寄存器
MOV CX,0;设置计数器为0; MOV CH,0读写:;顶读/写循环的
MOV AH,01H;准备好读取字符
INT 21H;读取字符到AL; JB读写MOV [BX],AL; AL移动到内存DS:BXCX加1;递增计数器
加BX,1;增量抵消CMP AL,$;比较进入到$
JG读写;如果(C&0)环;反转打印MOV BX,0800H
MOV DS,BX;设置段寄存器
MOV BX,0000H;设置失调寄存器
加BX,CX
子BX,2MOV AH,0EHMOV AL,010; NL
INT 10H
MOV AL,013; CR
INT 10Hrevprinting:
MOV AL,[BX]
INT 10H
子BX,1
子CX,1
CMP CX,1
JG revprintingRET


解决方案

您可以跳过IF-部分。除了使用20小时为ASCII大写和小写的区别,你可以使用的比特上午十时正。 5(ASCII字符:上午十位7,......,位0上午十时正)。通过设置ASCII字符的第5位为1,你会得到一个小写字母。通过设定5位为0,你得到的大写字母。

获取小写。设置位5至1:

 和人,0xdf;你可能在你的符号来代替0xdf DFH

获取大写。设置位5至0:

 或人,0x20的; 20H

这是很有用的检查一个charakter是否为字母或没有得到很好的。您只需设置所有字母为大写。之后,你用CMP检查charakter是否低于'A'以上'Z'。如果没有,那么它是一个字母。

;I created this program (Intel 8086 Assembly) to read characters and store them and print ;them in reverse order after converting them to Upper Case. I know you can convert to upper ;case using (sub AL, 20h) but how do I put the conditional (IF) Loop ?

org 100h
mov BX, 0800h
mov DS, BX      ;Set segment register
mov BX, 0000h   ;Set offset register
mov CX, 0       ;Set counter to 0      

;mov CH, 0

readwrite:      ;Top of read/write loop
mov AH, 01h     ;Get ready to read a character
int 21h         ;Read character into AL 

;jb readwrite

mov [BX], AL    ;Move AL into memory at DS:BX

add CX, 1       ;Increment Counter 
add BX, 1       ;Increment offset      

cmp AL, '$'     ;Compare entered to $
jg readwrite    ;if (C > 0) loop



;Reverse Printing

mov BX, 0800h
mov DS, BX      ;Set segment register
mov BX, 0000h   ;Set offset register            
add BX, CX
sub BX, 2            

mov AH, 0eh  

mov AL, 010 ;NL
int 10h
mov AL, 013 ;CR  
int 10h



revprinting:
mov AL, [BX]
int 10h    
sub BX, 1
sub CX, 1
cmp CX, 1
jg revprinting

ret

解决方案

You can skip the IF-Part. Instead of using 20h as the difference between upper case and lower case in ASCII, you can use the Bit Nr. 5 (ASCII-character: Bit Nr. 7, ... , Bit Nr. 0). By setting Bit 5 of an ASCII-character to 1, you get a lower case letter. By setting Bit 5 to 0, you get the upper case letter.

Get lower case. Set Bit 5 to 1:

and al, 0xdf  ; you may use dfh instead of 0xdf in your notation

Get upper case. Set Bit 5 to 0:

or al, 0x20  ; 20h

This can be usefull to check whether a charakter is a letter or not as well. You simply set all letters to upper case. After that you check with "cmp" whether the charakter is below 'A' or above 'Z'. If not, then it is a letter.

这篇关于英特尔8086大会转换小写字母大写。如果已经处于大写DO_NOTHING并继续保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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