lea si, msg ; ds:si points to message
mov cx, 7 ; cx holds message length
toupper:
mov al, [si] ; al holds current letter
cmp al, 97
jb skip
cmp al, 122
ja skip
sub al, 32 ; capitalize letter
mov [si], al ; replace letter
skip:
inc si ; move to next letter
loop toupper ; loop 7 times
mov ah, 09 ; print function
lea dx, MSG ; load string to be printed
int 21h ; call DOS
int 20h ; exit to DOS
MSG DB “GraInNe$” ; define message
All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.
Accordingly you can also do this to determine string length
MSG DB "gRAinNE$" ; define message
EMSG EQU $-MSG-1 ; msg length - 1
lea si, msg
mov cx, EMSG ; cx holds message length
The line "EMSG EQU $-MSG-1". EQU is an assembler directive similar to the "db" instruction (db stands for declare byte) EQU declares constants, that is, after you've used EQU to assign a value to a variable, you cannot change the variable's value afterwards.
Refer to $-MSG-1. Aside from '$' being string terminator, it can also signify "your location in the program". So basically, "$-MSG-1" signifies the current location minus the (MSG) start of string, which is consequently, the length of the string! -1, because string starts from 0 to length-1.
Posted by phengpheng at August 6, 2006, 12:46 pm