Having a bit of difficulty getting my input to print once a white space character is inputted. So far, i have it to display the uppercase/lowercase of the input but once i enter a string it doesnt read whats after the white space character. any suggestions?
EDIT: intel x86 processor and im using EMU8086
org 100h
include 'emu8086.inc'
printn "Enter string to convert"
mov dx,20
call get_string
printn
mov bx,di
mov ah,0eh
mov al,[ds+bx]
cmp al, 41h
cmp al, 5Ah
jle ToLower1
cmp al, 61h
cmp al, 7ah
jle ToUpper1
ToLower1:
add al, 20h
int 10h
jmp stop1
ToUpper1:
sub al, 20h
int 10h
stop1:
inc bx
mov al,[ds+bx]
cmp al, 41h
cmp al, 5Ah
jle ToLower2
cmp al, 61h
cmp al, 7ah
jle ToUpper2
ToLower2:
add al, 20h
int 10h
jmp stop2
ToUpper2:
sub al, 20h
int 10h
stop2:
inc bx
mov al,[ds+bx]
cmp al, 41h
cmp al, 5Ah
jle ToLower3
cmp al, 61h
cmp al, 7ah
jle ToUpper3
ToLower3:
add al, 20h
int 10h
jmp stop3
ToUpper3:
sub al, 20h
int 10h
stop3:
inc bx
mov al,[ds+bx]
cmp al, 41h
cmp al, 5Ah
jle ToLower4
cmp al, 61h
cmp al, 7ah
jle ToUpper4
ToLower4:
add al, 20h
int 10h
jmp stop4
ToUpper4:
sub al, 20h
int 10h
stop4:
inc bx
mov al,[ds+bx]
cmp al, 41h
cmp al, 5Ah
jle ToLower5
cmp al, 61h
cmp al, 7ah
jle ToUpper5
ToLower5:
add al, 20h
int 10h
jmp stop5
ToUpper5:
sub al, 20h
int 10h
stop5:
printn
hlt
define_get_string
define_print_string
end
@Oded, those registers are x86 and emu8086 would imply an emulator for the 8086 CPU.
@OP:
Well your adding 32 to a character code to make it lower right? The ASCII code for
spaceis 32 and the ASCII code for the@symbol is 64 right? That should tell you your compares are wrong somewhere.Do you see the error? This is basically telling the CPU if the current character is equal to or less than
Zto make lower. Also, if the character is equal to or less than z to make upper.So what you have is:
You need a conditional jump after
cmp al, 41Hand a conditional jump aftercmp al, 61HBut that still won’t work, this should work:
* Edit *
We can condense all that code into 1 loop: