Simple assembly language problem...

JohnCU

Banned
Dec 9, 2000
16,528
4
0
I'm trying to start using arrays in assembly language. I have to look at a string, and look at each character in the string, and if it is capital, make it a lower case.

movl $0,%ecx

for: movl %ecx,%edi
cmpl length,%ecx
jge end
cmpb $65, string(,%edi,1)
jl next
cmpb $90, string(,%edi,1)
jg next
movb string(,%edi,1), %al
addb $32, %al
movb %al, string(,%edi,1)
addl $1, %ecx
jmp for

why doesn't that work?
 

imported_FishTaco

Golden Member
Apr 28, 2004
1,120
0
0
My x86 assembly is rusty, but I'll give it a shot if you post more info about what your program is doing wrong. Also use the Attach Code button to add your code to your post.
 

JohnCU

Banned
Dec 9, 2000
16,528
4
0
It isn't altering the string (ie. it isn't lower-casing the stuff like it is supposed to).
 

imported_FishTaco

Golden Member
Apr 28, 2004
1,120
0
0
Well, you seem to be missing your next and end labels. Also I'm not sure, but I think cmpl can only compare 2 registers. Can you post the whole program?
 

JohnCU

Banned
Dec 9, 2000
16,528
4
0
That's the only part so far, I just want to get that part working. Next just goes to the end of the program right now. Cmp works with comparing one thing and one register, it doesn't have to be 2 registers.
 

imported_FishTaco

Golden Member
Apr 28, 2004
1,120
0
0
jg and jl are suppossed to conditionally jump to a label. You have them jumping to "next", but I don't see a "next:" label in your code. It would appear that you want to jump to the instruction that increments your counter but it's not labeled as "next:".
 

JohnCU

Banned
Dec 9, 2000
16,528
4
0
Yeah, I left that part out, i'm just trying to get this piece of the code working now. I don't care what it jumps to at the moment, as long as the string has characters between A and Z. I just want to type in an 'A', and get out an 'a'.
 

JohnCU

Banned
Dec 9, 2000
16,528
4
0
okay, nevermind, my code works, my compiler does not. Sun machine #2 has failed me. :(