:(
Hello,
I?m new to assembler language and I have no idea why this program doesn?t work.The program should caps a letter.Please tell me if you can where I went wrong.
DOSSEG
.model small
.data
mesaj1 db 'Give the small letter $'
mesaj2 db 'The big letter is $'
asc_diff db 32 ;the diffrence from A to a,,, (A=65,a=97)
in_char db ?;will contain the inputed char (small letter)
out_char db ?;will contain the output char (high letter)

.code
start:
mov ax,@data
mov ds,ax

mov ah,09h ;displaying the introduction message
mov dx,offset mesaj1
int 21h
xor al,al
reading:
mov ah,01 ;subfunction 01
mov in_char,al ;gets the char into "in_char"
int 21h ;get the Char from keyboard




CMP AL, 97 ; if below jump to exit.
JB exit

CMP AL, 122 ; if above jump to exit.
JA exit
transformation:
sub al,asc_diff ;we want to make 97(a) 65(A)
mov out_char,al ;moving the changed char to "out_char"
mov ah,02 ;subfunction 02
mov dl,10 ;line feed
int 21h
mov dl,13 ;carridge return
int 21h
mov ah,09h ;afisarea mesajului de introducere date
mov dx,offset mesaj2
int 21h
xor al,al
mov dl, out_char ;outputting the capsed char
int 21h


exit:
mov al,00
mov ah,4ch
int 21h

END
Posted on 2002-05-25 17:25:19 by newbier
Hi newbier,

I optimized and convert ideal model your example. You can use CR,LF after string+ 0ah,0dh+$ like below:




[b]
.data
mesaj1 db 'Mesaj1',0ah,0dh
db 'Mesaj2',0ah,0dh, '$'
[/b]



Working copy here. :)





ideal
p386

segment code
assume cs:code

org 100h

start:
jmp stpoint

mesaj1 db 'Give the small letter $'
mesaj2 db 'The big letter is ',0ah,0dh ; text+cr,lf
asc_diff db 32
in_char db ?
out_char db ?
db '$'

stpoint:

mov ah,09h ;displaying the introduction message
mov dx,offset mesaj1
int 21h
xor al,al
reading:
mov ah,01 ;subfunction 01
mov [in_char],al
int 21h
CMP AL, 97
JB exit
CMP AL, 122
JA exit
transformation:
sub al,[asc_diff ] ; or you can use xor al,20h
mov [out_char],al

mov ah,09h
mov dx,offset mesaj2
int 21h

exit:
mov ax,04c00h
int 21h

ends code
end start


Compile with TASM :



tasm32 /z example
tlink /t example
del *.obj




have nice days,
Posted on 2002-05-25 20:48:19 by CYDONIA