Home > Percussion > Case Masm

Case Masm

January 12th, 2011 admin Leave a comment Go to comments

Quick Assembly question before my program is due at 12?

I have my code very close to working correctly, but all that I am getting when I test it is dollar signs.

I wrote a program in assembly to convert user input to all capital letters, ending on a period. Any help with what I am doing wrong to make this program run correctly would be appreciated more than you can imagine.

My code is:

.model small
.8086
.stack 256
.data
str1 db 50 dup('$')
.code
start:
mov ax, @data
mov ds, ax
mov bx, @data
int 21h
lea si, str1
xor cx, cx
upper_case:
mov ah, 01h
int 21h
cmp al, 2Eh
jz done

mov [si], al

; check if it's a lower case letter:
cmp byte ptr [si], 'a'
jb ok
cmp byte ptr [si], 'z'
ja ok

and byte ptr [si], 11011111b
ok:
inc si
inc cx
jne upper_case

stop:
mov ah, 09h
int 21h
lea si, str1
done:
mov dl, [si]
mov ah, 02h
int 21h
inc si
dec cx
jnz done

mov ax, 4C00h
int 21h
space:

end start

I am compiling with DOSbox and MASM.

Thanks!!!!

You need to swap these two lines:
lea si, str1
done:

To become:
done:
lea si, str1

This is because you are trying to print str1 which starts at [si]

==========

Hints:
create a list of allowable characters using db
each allowable character is paired with it's output character.
getch
create a loop to search if character is allowed
then print the paired character instead of the allowed character.

This should shrink your assembly program to alot less lines.

Doumbek Aluminium Mini Silver Drum w Case MASM SL
Doumbek Aluminium Mini Silver Drum w Case MASM SL
$69.88
Time Remaining: 11d 17h 39m
Buy It Now for only: $69.88


Account limit of 2000 requests per hour exceeded.
Categories: Percussion Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.