: Now i was given a task, which is read a data which was given in the program and convert it into uppercase! but i fail to do it. now i post example of the program and hopefully got kind people help me to check where is the problem.thanks....
:
: EXAMPLE:
: ;convert.asm
: .model small
: .stack 200h
: .data
: message1 Db 'abCdEF ghO/"0()ijklwmohcoc'
:
: .code
: start:
: mov ax, seg message1
: mov ds, ax
:
: mov di, offset message1
: mov bl,[di]
whats all this for? Your index is di. What if you had a junk value in di
: mov bh,0
:
:
: mov BYTE PTR [BX+di],'$'
???
: add bx, 2
:
: lowercase:
: cmp byte ptr [bx], 'a'
: jb character
Not needed
: cmp byte ptr [bx], 'z'
: ja character
: and byte ptr [bx], 11011111b
:
: character:
: inc bx
: loop lowercase
: mov dx, di
: mov ah,09
: int 21h
:
: Last:
: mov ax,4c00h
: int 21h
: End start
:
Maybe
cld
mov si, offset mystring
To_Uppercase:
cmp byte [si], '$'
je Done
lodsb
and al, 11011111b
mov [ds:si-1], al
jmp To_Uppercase
Done:
ret
mystring db "abCdEF ghO/"0()ijklwmohcoc", '$'
Here's a program that takes input from the keyboard that I made and converts to uppercase.
;NASM-IDE ASM Assistant Assembler Project File
BITS 16 ;Set code generation to 16 bit mode
ORG 0x0100 ;Set code start address to 0100h
;TO UPPERCASE USING DOS SERVICES, SIMPLER VERSION!
SEGMENT .text ;Main code segment
mov ax, 0003h
int 10h
mov ah, 9
mov dx, msg
int 21h
mov ah, 0ah
mov dx, buffer
int 21h
mov si, buffer+2
cld
call To_Uppercase
mov ah, 9
mov dx, crlf
int 21h
mov ah, 9
mov dx, toupper
int 21h
mov ah, 9
mov dx, buffer+2
int 21h
mov ah, 9
mov dx, crlf
int 21h
mov ah, 9
mov dx, anykey
int 21h
mov ah, 0
int 16h
mov ax, 4c00h
int 21h
To_Uppercase:
cmp byte [si], '$'
je Done
lodsb
and al, 11011111b
mov [ds:si-1], al
jmp To_Uppercase
Done:
ret
SEGMENT .data ;Initialised data segment
msg db "Please enter up to 16 characters to convert to uppercase: ",'$'
buffer db 17
db 0
times 17 db 0
db '$'
crlf db 10,13,10,13,'$'
toupper db "Conversion to uppercase: ",'$'
anykey db "Press any key to continue",'$'
SEGMENT .bss ;Uninitialised data segment