| |
| |
| |
|
Page: 1 2
<liquidengineer> Hello <liquidengineer> I'm programming in x86 asm <liquidengineer> and wondering if, given a character I'm storing in an 8-bit register (AL), if there's a simple way I can test to see if that character is a digit <wcstok> check if it's >='0 and <='9' <liquidengineer> Oh <liquidengineer> yes <liquidengineer> that would do it <liquidengineer> but I didn't think I could do that with a single cmp and jump pair <liquidengineer> i.e.: I want to jle 9 AND jge 0 <liquidengineer> I don't quite understand how to do a multi-conditional jump <liquidengineer> I could test for one and if it's true jump to a block where I test the other and jump if THAT one's true/not true, but that seems overcomplicated <pireau> liquidengineer: i got a program here <pireau> for DOS, but you could easily port it.. <pireau> it prints a X bytes <pireau> mov dx,XXXXh ; contains the value to be printed <pireau> mov cx,XXh ; contains the number of bytes to be printed. <pireau> would you like it ? <pireau> it has the the part where I convert the numerical value to it's ASCII value. <liquidengineer> Hmm....thanks, but I'm not sure I need it... <liquidengineer> Or maybe I do need to do that <pireau> http://rafb.net/paste/results/YqGvvm65.html <liquidengineer> I'm confused <pireau> just check, it's commented ;) <liquidengineer> is it legal to compare like this? <liquidengineer> cmp inputBit, '0' <liquidengineer> and then do a jge statement? <pireau> jae <pireau> jge is for signed numbers... <liquidengineer> jae does what, then? <pireau> it actually the same, but it's better for you when you'll read this code in 5 years <liquidengineer> jmp if alpha equal? <pireau> Jump Above or Equal <pireau> Jump Greater or Equal <pireau> same. <pireau> 1st, what are you trying to do ? <liquidengineer> I have an input <liquidengineer> I need to know if the input character (stored in AL) is alpha <liquidengineer> if it's a character that's not a digit, I just need to output it <liquidengineer> if it's a digit between 0 and 9, I need to xlatb it <pireau> you could mod hte code to work... <pireau> where i add 30h, you could just output it <pireau> oh no <pireau> you already have it's ASCII value <pireau> numbers are between 30h and 39h. <pireau> alpha are 41h + 1Ch <liquidengineer> yeah <liquidengineer> I already have the ascii value <liquidengineer> so... <liquidengineer> I'm looking at this <pireau> if <=39h AND >=30h -> out put <liquidengineer> cmp dx,0Fh ; If num is <=0Fh AND >=0 <pireau> else -> xlatb <pireau> but first you cheack that the value is between 30h and 5Ch <pireau> yeah <pireau> cmp dx,0Fh ; If num is <=0Fh AND >=0 <pireau> ja EndIfDetAffiche; <pireau> cmp dx,0 ; <pireau> jb EndIfDetAffiche; <pireau> if it's higher than F jump to EndIf <pireau> else it executes the other cmp <liquidengineer> yeah, I was looking at that part <pireau> it it's below than 0 jump to end if... <liquidengineer> what's F? <pireau> 0Fh <pireau> 1111 ? <pireau> 15 ? <liquidengineer> oh <pireau> 17 in octal ? <pireau> because here i print a numerical value. <pireau> so it's between 0 and 9 and A and F <liquidengineer> yeah <liquidengineer> so since I'm working in base 10.... <pireau> but i have to know it's its a number or a letter to add ghe right value to it to get it's ASCII value... then print it. <pireau> work in base 16 ;) <liquidengineer> I'd rather not... :P <liquidengineer> but I might end up having to <pireau> yu <pireau> yup* <liquidengineer> I have a question about this: <liquidengineer> cmp dx,0Fh ; If num is <=0Fh AND >=0 <pireau> yeah ? <liquidengineer> how does it test BOTH those conditions? <pireau> the if is accomplished with the 2 compares... <liquidengineer> how do you know it's greater than 0? <liquidengineer> OH <liquidengineer> yaeh <liquidengineer> so you DO need two compares <liquidengineer> well then <liquidengineer> poo <pireau> yah <liquidengineer> I was hoping I could do it with one <pireau> nah <pireau> i'd be glad to code a part with you <liquidengineer> I'm hoping I can get this to work with my decimal implementation, since I've already got like 80 lines written <liquidengineer> so, first I would do something like this, right? <pireau> first <liquidengineer> cmp AL,9 <liquidengineer> ? <pireau> nein <liquidengineer> oops <liquidengineer> okay then. :) <liquidengineer> what should I do first? <pireau> first test if it's between 30h and 7Ah <pireau> since you could have a 'A' or a 'a' <liquidengineer> actually, I was hoping not to test for letters <liquidengineer> as it is, my program essentially ignores alphanumeric input <liquidengineer> it just gets echoed out <liquidengineer> *alpha input <liquidengineer> I was hoping just to test for 0-9 <eedy31> yellow <pireau> okay <liquidengineer> those 10 are the ones I need to take action on <pireau> then only test if the value is between 48 and 57. <pireau> if it's not... it's an alpha or a control code or anything else. <pireau> cmp al,57 <pireau> ja EndIfNum <pireau> cmp al,38 <pireau> jb EndIfNum <pireau> ;treatement here <pireau> EndIfNum <pireau> like so. <pireau> you need a ':' after EndIfNum <liquidengineer> Where EndIfNum is run if it's NOT a number, right? <pireau> yeah <pireau> so you place your "treatement code" between the comment and the label. <liquidengineer> I think I got it, thanks! <liquidengineer> but you were right <liquidengineer> I just looked at the what I already had written <liquidengineer> I have the xlatb instruction inside a labeled codeblock called encrypt <liquidengineer> it is better to test for alphas and just jump OVER the xlatb if I don't need it <pireau> cool <pireau> glad I could help <liquidengineer> so in the example you gave me I just substitute cmp al,57 for 30h and so forth, right? <pireau> yeah <pireau> that;s what I did. <liquidengineer> thanks <liquidengineer> I'm sure listening ot me restate things is frustrating, but I have trouble understanding sometimes. :) <liquidengineer> crud <liquidengineer> gotta go <liquidengineer> later <liquidengineer> :d <CaffeiniaNervosa> Hello. <Nomius> What does the cwd instruction in x86? <wcstok> convert word to doubleword <Nomius> Thanks <prolific> What is actually converted with that instruction? <libero> if you just copy the word into a dw, it copies the least significant 8 bytes only <libero> and doesn't make sure that the most sig. bytes are managed correctly <libero> cwd will do that <prolific> So if you have 10000101000000000 and movl that into a dw, you get 0000[16 0's]0001000010100000000, right? <prolific> Well, something like that
Return to asm or Go to some related
logs:
lazy evaluation c++ corporal trinket football
|
|