flat assembler
Message board for the users of flat assembler.
Index
> Main > Fasm 1.73 Many cmp one jz. Goto page 1, 2 Next |
Author |
|
ProMiNick 10 Mar 2020, 05:53
cmp eax,23
ja notinTbl jmp [eax*4+JmpTbl] JmpTbl: dd case0 dd case1 dd case2 dd case3 dd case4 dd case5 dd case6 dd case7 dd case8 dd case9 dd case10 dd case11 dd case12 dd case13 dd case14 dd case15 dd case16 dd case17 dd case18 dd case19 dd case20 dd case21 dd case22 dd case23 case1: case3: case4: case5: case11: case13: case23: Msg 'OK' notinTbl: other cases somewhere else (they equal notinTbl forexample) |
|||
10 Mar 2020, 05:53 |
|
Roman 10 Mar 2020, 06:23
Thanks.
I thinked exist simple asm command for my case. Many times I see that there are not enough many useful commands in modern CPU. If modern CPU have many simples and powerfuls asm commands. Many peoples writes program on fasm. And not used c++. My opinion Intel not good implemented asm commands for easy write code. This led to the emergence of c ++ Intel should be ashamed for this |
|||
10 Mar 2020, 06:23 |
|
revolution 10 Mar 2020, 06:41
Roman wrote: Thanks. |
|||
10 Mar 2020, 06:41 |
|
Tomasz Grysztar 10 Mar 2020, 07:24
If this is a simple yes/no check with multiple numbers for each case, you could save space by using a bit field and BT instruction:
Code: mov eax,4 cmp eax,32 jae ok bt [bits],eax jc @f ok: invoke MessageBox,0,'ok',0,0 @@: Code: bits: dd 1 shl 3 \ or 1 shl 4 \ or 1 shl 5 \ or 1 shl 11 \ or 1 shl 13 \ or 1 shl 23 Code: mov eax,111 cmp eax,256 jae ok bt [bits],eax jc @f ok: invoke MessageBox,0,'ok',0,0 @@: Code: bits: emit 256/8: 1 shl 3 \ or 1 shl 4 \ or 1 shl 5 \ or 1 shl 11 \ or 1 shl 13 \ or 1 shl 23 \ or 1 shl 111 |
|||
10 Mar 2020, 07:24 |
|
revolution 10 Mar 2020, 12:35
Roman wrote: Some time need do many compares. How do many cmps and one jz ? Code: mov r0,4 cmp r0,5 cmpne r0,3 cmpne r0,11 cmpne r0,13 cmpne r0,23 cmpne r0,4 cmpne r0,1 beq @f Msg 'ok' @@: |
|||
10 Mar 2020, 12:35 |
|
Roman 10 Mar 2020, 15:07
Its good example how arm architecture more thoughtful.
Why Intel do not develop new asm commands and do not speed up x86 CPU ? Efective asm commands give less code and increase speed. |
|||
10 Mar 2020, 15:07 |
|
revolution 10 Mar 2020, 16:15
Roman wrote: Efective asm commands give less code and increase speed. |
|||
10 Mar 2020, 16:15 |
|
Roman 10 Mar 2020, 17:11
Quote: So perhaps all that extra circuitry to support CMPcc is too much of a burden and holds it back? This question should be asked to engineers , who develops modern CPU. And how do this more efective. |
|||
10 Mar 2020, 17:11 |
|
Roman 10 Mar 2020, 17:37
Good example inverse matrix 4x4 ! Nice have one sse asm command.
Inverse matrix 4x4 174 asm sse commands ! It's hard to write 174 asm commands and do not make mystake ! Or one sse command two matrix4x4 multiply. Or cross product. Quaternion very handfull in math and physics. But Intel not do this in new AVX instructions. I think this is probably one of the many reasons why Intel it loses to AMD Ryzen. No new efective instruction and does not develop new CPU architectures. |
|||
10 Mar 2020, 17:37 |
|
DimonSoft 11 Mar 2020, 07:00
Roman wrote: Its good example how arm architecture more thoughtful. You would cry seeing how certain easy things (like, say, loading a 32-bit immediate) are done in ARM. |
|||
11 Mar 2020, 07:00 |
|
DimonSoft 11 Mar 2020, 07:06
Roman wrote: Good example inverse matrix 4x4 ! Nice have one sse asm command. What would the inverse matrix instruction do with a zero-determinant matrix? Does AMD Ryzen have such instructions or you’re just trying to use your personal preferences to explain something unrelated? Think about it. |
|||
11 Mar 2020, 07:06 |
|
revolution 11 Mar 2020, 07:27
A "good" example where ARM vs x86 and ARM loses is getting the parity of a number. x86 has a handy flag giving you the parity, ARM has no equivalent, you have to do it longhand.
For most applications this makes no difference, since very few care about the parity. But if your app does make heavy use of parity then you will love x86 and hate ARM. |
|||
11 Mar 2020, 07:27 |
|
Tomasz Grysztar 11 Mar 2020, 08:12
revolution wrote: A "good" example where ARM vs x86 and ARM loses is getting the parity of a number. x86 has a handy flag giving you the parity, ARM has no equivalent, you have to do it longhand. |
|||
11 Mar 2020, 08:12 |
|
revolution 11 Mar 2020, 09:01
Thanks. I meant the sum of all bits modulo 2. Comms and protocol documents tend to use this definition of parity.
Indeed, the parity in the mathematical sense would simply be the LSb, which is trivial to get in both x86 and ARM. |
|||
11 Mar 2020, 09:01 |
|
guignol 18 Apr 2020, 11:47
I was nearly shocked...
and what do you think of https://amperecomputing.com/ampere-altra-industrys-first-80-core-server-processor-unveiled/ |
|||
18 Apr 2020, 11:47 |
|
Overclick 23 Jul 2020, 07:57
Use this macro
Code: macro cmp arg1, [arg2] { common counter = 0 forward counter = counter + 1 common if counter > 1 push eax xor eax,eax forward cmp arg1,arg2 lahf or al,ah common mov ah,al sahf pop eax else cmp arg1,arg2 end if } Examples: cmp eax,13 ;compiled as usual nothing extra in code je @F cmp eax,13,11,56,44 ;compiled as flags stacker je @F |
|||
23 Jul 2020, 07:57 |
|
revolution 23 Jul 2020, 10:24
Overclick wrote: Use this macro ... So your example "cmp eax,13,11,56,44" will likely fail. |
|||
23 Jul 2020, 10:24 |
|
Overclick 23 Jul 2020, 14:14
Fixed
For 32 bit version it needs to change registers to eax esp Code: macro cmp arg1, [arg2] { counter = 0 forward counter = counter + 1 common if counter > 1 push rax xor rax,rax push rax forward mov rax,[rsp+8] cmp arg1,arg2 lahf or [rsp],ah common pop rax mov ah,al sahf pop rax else cmp arg1,arg2 end if } Even better if eax not in use Code: macro cmp arg1, [arg2] { counter = 0 forward counter = counter + 1 common if counter > 1 push rax xor rax,rax push rax forward if `arg1 in <'rax','eax','ax','ah','al'> | `arg2 in <'rax','eax','ax','ah','al'> mov rax,[rsp+8] end if cmp arg1,arg2 lahf or [rsp],ah common pop rax mov ah,al sahf pop rax else cmp arg1,arg2 end if } |
|||
23 Jul 2020, 14:14 |
|
bitRAKE 23 Jul 2020, 15:44
<OFF TOPIC> fasmg
Code: macro compare reg0,N& iterate n,N cmp reg0,n if %% > 1 pushfq if % = %% repeat %% - 1 pop reg0 or [rsp],reg0 end repeat popfq end if end if end iterate end macro compare r15, 0xFF0000,0xFF00,0xFF for byte/word size set tests the SIMD string instructions are very effective: PCMP?STR?. the implicit memory forms are not that slow - requires SSE4.2 though. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
23 Jul 2020, 15:44 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.