1 Replies - 176 Views - Last Post: 05 July 2013 - 08:24 PM Rate Topic: -----

#1 airojohn24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-April 12

problem in displaying alternate upper and lower case

Posted 05 July 2013 - 08:20 PM

.model small
.stack 100h
.data
	a db 13,10, 'Number(1-9):',36
	b db 13,10, 'Letter(a-z or A - Z): ', 36
	c db 13,10,'Output: ',36
	d db 13,10,'Invalid Input. Try again?[y/n]',36
	
.code

	mov ax, @data
	mov ds,ax
Num1:   mov ah,09h
	lea dx, a
	int 21h

	mov ah, 01h
	int 21h

	cmp al, 31h ; 1
	jb error

	cmp al, 39h ; 9
	ja error
	
	mov cl, al
	
Letter1:
	mov ah, 09h
	lea dx, b
	int 21h

	mov ah, 01h
	int 21h
	
	mov bl, al

	cmp bl, 41h ;A
	jb error
	cmp bl,7ah ;z
	ja error
	cmp bl, 41h ;A
	jae UC
	
	mov ah, 09h
	lea dx, c
	int 21h
	
UC:
	cmp bl, 5ah;Z determines if bl is uppercase
	jbe proc1
	cmp bl, 7ah;z determines if bl is lowercase
	jbe proc2
	
proc1:
	sub cl,01h
	
	cmp cl,30h; 0
	je Num1
	
	mov ah,02h
	mov dl,bl
	int 21h
	
	add bl,20h
	
	jmp UC
proc2:
	sub cl,01h
	
	cmp cl,30h; 0
	je Num1
	
	mov ah,02h
	mov dl,bl
	int 21h
	
	sub bl,20h
	
	jmp UC
	
	error: mov ah, 09h
	lea dx, d
	int 21h
	
	mov ah, 01h
 	int 21h
	
	cmp al, 79h ;y
	je Num1
	cmp al, 59h ;Y
	je Num1
	cmp al, 4eh ;N
	je exit
	cmp al, 6eh ;n
	je exit
	
	jmp error

	exit:mov ah, 4ch
 	int 21h
	end



Example Output:

Number(1-9): 5
Letter(a-z or A - Z): A
Output: AaAaA

Number(1-9): 5
Letter(a-z or A - Z): a
Output: aAaAa

My Output:

Number(1-9): 5
Letter(a-z or A - Z): A
Output: AAaAa

Number(1-9): 5
Letter(a-z or A - Z): a
Output: aaAaA

The first two letters are not alternated.

Is This A Good Question/Topic? 0
  • +

Replies To: problem in displaying alternate upper and lower case

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9392
  • View blog
  • Posts: 35,268
  • Joined: 12-June 08

Re: problem in displaying alternate upper and lower case

Posted 05 July 2013 - 08:24 PM

Please do not create duplicate topics. closing.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1