Tuesday 1 March 2016

Assembly Program to convert string from lower case to upper case

 
;Program to convert string from lower case to upper case      org 100h
; add your code here
mov bx, offset str      ;load address of fisrt byte of str

repeat:
mov al, [bx]            ;load first byte of address store in bx
cmp al, '$'             ;check is it $ i.e. end of string
je print                ;if yes then goto print label

sub al, 20h             ;otherwise convert it into upper case by subtracting 20h
mov [bx], al            ;move back to str
inc bx                  ;move to next byte of str
jmp repeat              ;goto repeat

;this code section print str
print:
mov ah, 09h
mov dx, offset str
int 21h
ret
;data section
str db 'abcdefghijklmnopqrstuvwxyz','$'

No comments:

Post a Comment