flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
mindcooler 03 Nov 2010, 17:42
edx = (((eax>='a') and (eax<='z')) or ((eax>='A') and (eax=<'Z'))) or (eax='_')
Code: .checkalpha: xor ecx,ecx xor edx,edx cmp al,'_' je .alpha cmp al,'A' setae cl cmp al,'Z' setbe dl and dl,cl jnz .alpha xor ecx,ecx cmp al,'a' setae cl cmp al,'z' setbe dl test dl,cl jnz .alpha .nonalpha: xor edx,edx retn .alpha: retn _________________ This is a block of text that can be added to posts you make. |
|||
![]() |
|
baldr 03 Nov 2010, 17:46
ishkabible,
You may look at compilers' output. They actually use de Morgan's rules to simplify conditionals. Mr. Hyde's comment: there ain't such thing as best way: you must supply criteria to decide. ----8<---- mindcooler, Isn't cmp al,'_' / je .alpha misleading? Last edited by baldr on 03 Nov 2010, 17:50; edited 1 time in total |
|||
![]() |
|
mindcooler 03 Nov 2010, 17:49
In my implementation, _ was included in the definition of alphanumeric.
|
|||
![]() |
|
baldr 03 Nov 2010, 17:51
mindcooler,
Oh, I see. ![]() |
|||
![]() |
|
mindcooler 03 Nov 2010, 17:52
To answer the question in the title, I would implement && as and.
|
|||
![]() |
|
baldr 03 Nov 2010, 17:55
mindcooler,
Bitwise and? Heh, maybe I've found another FORTH follower. ![]() P.S. 0= OVER 0= OR NOT . ![]() |
|||
![]() |
|
mindcooler 03 Nov 2010, 19:12
There is no other and. Or and and is implemented in hardware and no branches are necessary.
And I'm not FORTH, I'm afraid. (Not afraid of FORTH) |
|||
![]() |
|
baldr 03 Nov 2010, 19:22
mindcooler,
Boolean and (&& in C-speak) is nowhere near bitwise and (&), as you may see in simple 2&1==0. FORTH is nothing to be afraid about, you may like it. ![]() |
|||
![]() |
|
mindcooler 03 Nov 2010, 20:14
Solution is easy: stop using C booleans!
Nah, I gave up on HLAs when I met FASM. |
|||
![]() |
|
baldr 03 Nov 2010, 20:21
mindcooler,
Those who consider even the slight possibility of FORTH being HLA should be considered infidels. ![]() |
|||
![]() |
|
mindcooler 03 Nov 2010, 20:30
Well, it's _almost_ a stack machine language, but only almost
![]() |
|||
![]() |
|
baldr 03 Nov 2010, 20:47
mindcooler,
FORTH features unique synergy of being interpretive (in a way) and compilative (in a way, too), like fasm. Stack handling comes naturally when you're at expressions' evaluation, so why not? But CREATE … DOES> can't be beat, AFAIK. As always, we've been driven off-topic. ![]() |
|||
![]() |
|
ishkabible 03 Nov 2010, 20:52
bit-wise and can be used as the logical and operator on other Boolean values. take this
a <= b && b >= c is the same as a <= b & b >= c. just my little 2 cents. 1) thanks balder, i looked into de morgens rules, that should help 2) for criteria lets say that there is no context in witch the code will be used, just the fastest set of operations to set 'a' equal to the result of "b && c" i know it sounds strange but i think it will give me a good base line on how to implement it with out any special thought. i also am more specifically asking because i want to make an intermediate representation language so that i can do things like a = b + c or a+=c or even a[b]=c. as i was thinking how to implement each statement i came across things like "if a && b goto c" and "a = b && c" and was wondering how to best implement these in a 'raw' unoptimized form. that is why i am making the only criteria that there is no context and it needs to accomplish the task requested. i understand that is is almost impossible to find the 'defector' best way to do this, so i will state that i would like to see a reasonably fast solution. |
|||
![]() |
|
baldr 03 Nov 2010, 21:16
ishkabible wrote: 2) for criteria lets say that there is no context in witch the code will be used, just the fastest set of operations to set 'a' equal to the result of "b && c" ishkabible wrote: i know it sounds strange but i think it will give me a good base line on how to implement it with out any special thought. i also am more specifically asking because i want to make an intermediate representation language so that i can do things like a = b + c or a+=c or even a[b]=c. as i was thinking how to implement each statement i came across things like "if a && b goto c" and "a = b && c" and was wondering how to best implement these in a 'raw' unoptimized form. that is why i am making the only criteria that there is no context and it needs to accomplish the task requested. i understand that is is almost impossible to find the 'defector' best way to do this, so i will state that i would like to see a reasonably fast solution. |
|||
![]() |
|
ishkabible 03 Nov 2010, 23:59
thanks good advice, if i got no awnsers i was going to resort to this method, but from experience i have learned that if im not sure how to implement something i should see if someone else has useful insight on the subject.
Quote:
so i should look on the AMD website and see if there are any profiling tools? Quote:
im going to be making x86 applications so 8086. not completely sure what you mean by that but that is my answer, weather it's coherent and relevant or not i will let you be the judge. |
|||
![]() |
|
revolution 04 Nov 2010, 00:24
x86 means more than just 8086. x86 covers an entire class of CPUs that includes AMD, Via, Harris, Intel etc. as the makers and from the original 8086 up to the latest Athlon-X or i7 (or whatever is the latest). So when you say the 'fastest', you must specify precisely for which CPU it will be the fastest. And if you want it to be the fastest across all the CPUs then your task is impossible since they all behave differently and are optimised in different ways. Note that the speed is affected by the mobo and other external factors, so yo may need to specify these things also.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.