Because if i had
Z 90 = 0b 0101 1010
z 122 = 0b 0010 0000
0b 0101 10101 | 0x20 would give me something else, not 122.
EDIT:
i think i made mistake in the calculation. brb
Because if i had
Z 90 = 0b 0101 1010
z 122 = 0b 0010 0000
0b 0101 10101 | 0x20 would give me something else, not 122.
EDIT:
i think i made mistake in the calculation. brb
You ended that sentence with a preposition...Bastard!
90 is 0b01011010, true. 122, however, is 0b01111010, not 0b00100000 which is just 32.
Yeah it worked.
I am going to try the reverse, convert from lower to upper. I don't understand why we AND, and not OR.
You ended that sentence with a preposition...Bastard!
I just did it. And I just had to do
a&~0x20...where did 0xdf come from, it works but why not use ~0x20? :S
You ended that sentence with a preposition...Bastard!
~0x20 is a negative number -224
0xdf is a positive 223.
btw, who is Gunga Din?
AND is used to clear, while OR was used to set? (all this binary...)
You ended that sentence with a preposition...Bastard!
Um, no. ~0x20 = 0b 1101 1111, while 0xdf is 0b 1101 1111. (However, if I'm not mistaken, you can type 0xdf in an assembler program, while you can't type ~0x20. I might be wrong there though.)
Gunga Din - Wikipedia, the free encyclopedia
So, you do know what and means, right? And you do know what or means, right?
You ended that sentence with a preposition...Bastard!
tbh from that. All I can say is you could use the bitwise & to check if every bit is 0. Or to retain the original bits.
And the OR is used to set individual bits.
I wrote this code, and i have been getting seg fault. Can you help me spot what is wrong.I have been at it for half an hr. Ty
Code:#include <stdio.h> void cstring(char *s, char *d) ; int main() { char source[]="Hello World" ; char dest[12] ; printf("%s\n", source) ; cstring(source, dest) ; //printf("After function call: \n") ; // printf("%s\n", dest) ; //fputs(source, stdout) ; return 0 ; }Code:.section .data .section .text .global cstring cstring: push %ebp mov %esp, %ebp push %esi push %edi push %eax mov 12(%ebp),%esi #esi to point to source mov 8(%ebp),%edi # edi to point to dest copyLoop: cmpb $0, (%esi) je exit movb (%esi),%cl movb %cl, (%edi) inc %esi inc %edi jmp copyLoop exit: mov %ebp, %esp pop %eax pop %edi pop %esi pop %ebp ret .end
You ended that sentence with a preposition...Bastard!
Since arguments are pushed right-to-left, the one on the "top" of the stack (nearest ebp) is the first argument.
so it should be
movl 8(%ebp),%esi to point to source.
I tried that, i still got the same error
You ended that sentence with a preposition...Bastard!
Also:
means "SAY GOODBYE TO THE STACK!!!!!" The whole purpose of the pops is to bring esp down while moving the clobbered registers back to what they're supposed to be. If you fiddle with esp, now you're popping the old ebp into eax, the eip (i.e., where to return to from this function) into edi, probably the [11] byte of one of your strings (depending which one was loaded where) into esi, the [10] byte of that string into ebp [eep!] and then using the [9] byte of the string as the return address to jump to with ret. And that's not going to be pleasant.Code:mov %ebp, %esp