org 100h
jmp start
string db 20, 22 dup('?')
revstring db 20, 22 dup('?')
size dw 4
new_line db 0Dh,0Ah, '$'
start:
lea dx, string
mov ah, 0ah
int 21h
mov bx, dx
mov ah, 0
mov al, ds:[bx+1]
add bx, ax
mov byte ptr [bx+2], '$'
lea dx, new_line
mov ah, 09h
int 21h
lea bx, string
mov ch, 0
mov cl, [bx+1]
mov size, cx
jcxz null
add bx, 2
upper_case:
cmp byte ptr [bx], 'a'
jb ok
cmp byte ptr [bx], 'z'
ja ok
and byte ptr [bx], 11011111b
ok:
mov ah, byte ptr [bx]
push ax
inc bx
loop upper_case
mov cx, size
lea bx, revstring
reverse:
pop ax
mov byte ptr [bx], ah
inc bx
loop reverse
mov byte ptr [bx],'$'
lea dx, revstring
mov ah, 09h
int 21h
mov ah, 0
int 16h
null:
ret
Assembly code problem
Page 1 of 15 Replies - 953 Views - Last Post: 02 December 2012 - 08:38 PM
#1
Assembly code problem
Posted 02 December 2012 - 07:01 PM
I'm writing assembly code and I'm a bit out of my element. I'm having some difficulty getting this code to print the Uppercase characters to lowercase. Any suggestions? Here's what I have so far. Can anyone help me? I'm doing this using the EMU8086 which is designed for an Intelx86. Thanks in advance
Replies To: Assembly code problem
#2
Re: Assembly code problem
Posted 02 December 2012 - 07:16 PM
Let's move this on over to the Assembly Forum and to keep track of any other answers, cross posted Help displaying Uppercase to lowercase
Not posting that link..
Not posting that link..
#3
Re: Assembly code problem
Posted 02 December 2012 - 07:19 PM
I thought this was assembly section?
*** Edit ***
No, you posted in the "Other" section
*** Edit ***
No, you posted in the "Other" section
This post has been edited by GunnerInc: 02 December 2012 - 07:23 PM
#4
Re: Assembly code problem
Posted 02 December 2012 - 07:22 PM
Take a look at an ASCII table:
http://www.cdrummond...files/ascii.htm
Your checking to see if the value in bx is below 97 (a) and above 122 (z) so it will and -33 to everything else.. is that what you want?
Your going to need to use 4 cmps (maybe 5 or 6) to get this to work.
http://www.cdrummond...files/ascii.htm
cmp byte ptr [bx], 'a' jb ok cmp byte ptr [bx], 'z' ja ok
Your checking to see if the value in bx is below 97 (a) and above 122 (z) so it will and -33 to everything else.. is that what you want?
Your going to need to use 4 cmps (maybe 5 or 6) to get this to work.
#5
Re: Assembly code problem
Posted 02 December 2012 - 07:47 PM
took your advice and tried this with the same error still
I'm so confused. I tried this but it continues to give me AA when i input a value of AA.
cmp byte ptr [bx], 'a'
jb ok
cmp byte ptr [bx], 'z'
ja ok
and byte ptr [bx], 11011111b ;
cmp byte ptr [bx], 'Z'
jb ok
cmp byte ptr[bx], 'A'
ja ok
and byte ptr [bx], 11011111b ;
I'm so confused. I tried this but it continues to give me AA when i input a value of AA.
#6
Re: Assembly code problem
Posted 02 December 2012 - 08:38 PM
So, you need to reverse the string (which you got down) and change upper to lower and lower to upper like this?

Have a question for you though... when you give someone your phone number, do you give it in binary numbers or decimal? Why use binary numbers?
It's late and I need sleep, so I will leave you with this:

Have a question for you though... when you give someone your phone number, do you give it in binary numbers or decimal? Why use binary numbers?
It's late and I need sleep, so I will leave you with this:
upper_case: mov al, byte ptr [bx] cmp al, "A" jb CheckLower cmp al, "Z" ja CheckLower add byte ptr [bx], " " jmp ok CheckLower: cmp al, "a" jb ok cmp al, "z" ja ok sub byte ptr [bx], " " ok:
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote






|