flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > macro problem if numbers. |
Author |
|
macomics 11 Jul 2022, 17:49
Code: macro xmover chA,chB,[src,dst] { common if `chA eq "1" efff equ al else if `chA eq "2" efff equ ax else if `chA eq "4" efff equ eax else if `chA eq "8" efff equ rax end if xor ecx,ecx forward local .up .up: mov efff,[src+rcx] mov [dst+rcx],efff add ecx,chA cmp ecx,chA*chB jb .up } |
|||
11 Jul 2022, 17:49 |
|
ProMiNick 11 Jul 2022, 17:51
assembly if block will never affect on preprocessor equ (reason - stage mixing)
solution? for ex left all assignments & checks to preprocessor stage: Code: macro xmover chA,chB,[args,args2] { local .up common a@1 equ al a@2 equ ax a@4 equ eax a@8 equ rax efff equ a@#chA xor ecx,ecx forward .up: mov efff,[args+rcx] mov [args2+rcx],efff add ecx,chA cmp ecx,chA*chB jb .up } xmover 1,10,rsi,rdi xmover 2,10,rsi,rdi xmover 4,10,rsi,rdi xmover 8,10,rsi,rdi |
|||
11 Jul 2022, 17:51 |
|
Roman 11 Jul 2022, 19:41
Thanks.
Good solution. |
|||
11 Jul 2022, 19:41 |
|
Roman 12 Jul 2022, 08:16
Another problem with label .up. Label alredy defined .up.
Code: macro xmover chA,chB,[args,args2] { ;local .up common a@1 equ al a@2 equ ax a@4 equ eax a@8 equ rax a@16 equ xmm0 cmm@1 equ mov cmm@2 equ mov cmm@4 equ mov cmm@8 equ mov cmm@16 equ movups efff equ a@#chA cmm@ equ cmm@#chA xor ecx,ecx .up: forward cmm@ efff,[args+rcx] cmm@ [args2+rcx],efff common add ecx,chA cmp ecx,chA*chB jb .up } ;in code xmover 16,10,rsi,rdi,r10,r11 ;ok xmover 16,10,rsi,rdi,r12,r13 ;fasm get error .up alredy defined |
|||
12 Jul 2022, 08:16 |
|
macomics 12 Jul 2022, 08:38
Code: format binary use64 xmover_a@1 equ al xmover_a@2 equ ax xmover_a@4 equ eax xmover_a@8 equ rax xmover_a@16 equ xmm0 xmover_cmm@1 equ mov xmover_cmm@2 equ mov xmover_cmm@4 equ mov xmover_cmm@8 equ mov xmover_cmm@16 equ movups macro xmover chA,chB,[src,dst] { common local .up xor ecx,ecx .up: forward xmover_cmm@#chA xmover_a@#chA, [src + rcx] xmover_cmm@#chA [dst + rcx], xmover_a@#chA common add ecx, chA cmp ecx, chA * chB jb .up } xmover 16,10,rsi,rdi,r10,r11 xmover 16,10,rsi,rdi,r12,r13 ; fasm -m 1024 ./test.asm ; flat assembler version 1.73.30 (1024 kilobytes memory) ; 1 passes, 63 bytes. ; hexdump -C test.bin ; 00000000 31 c9 0f 10 04 0e 0f 11 04 0f 41 0f 10 04 0a 41 |1.........A....A| ; 00000010 0f 11 04 0b 83 c1 10 81 f9 a0 00 00 00 72 e3 31 |.............r.1| ; 00000020 c9 0f 10 04 0e 0f 11 04 0f 41 0f 10 04 0c 41 0f |.........A....A.| ; 00000030 11 44 0d 00 83 c1 10 81 f9 a0 00 00 00 72 e2 |.D...........r.| Khm. Why cmp ecx, chA * chB = 81 F9 0A 00 00 00, but cmp ecx, 10 = 83 F9 0A? |
|||
12 Jul 2022, 08:38 |
|
Roman 12 Jul 2022, 11:31
Quote:
Because xmover forbidden macro |
|||
12 Jul 2022, 11:31 |
|
FlierMate1 12 Jul 2022, 12:35
macomics wrote: Why cmp ecx, chA * chB = 81 F9 0A 00 00 00, but cmp ecx, 10 = 83 F9 0A? Because of the length of the operand? I too encounter similar instruction encoding: Code: 5: 05 d2 04 00 00 add eax,0x4d2 a: 83 c0 02 add eax,0x2 Shorter code for single byte value? |
|||
12 Jul 2022, 12:35 |
|
macomics 12 Jul 2022, 12:43
FlierMate1 wrote:
|
|||
12 Jul 2022, 12:43 |
|
revolution 12 Jul 2022, 18:01
macomics wrote: Both instructions have the same values. |
|||
12 Jul 2022, 18:01 |
|
macomics 12 Jul 2022, 18:53
revolution wrote: One is 0xa0, the other is 0x0a. |
|||
12 Jul 2022, 18:53 |
|
FlierMate1 12 Jul 2022, 20:50
revolution wrote:
I paste the two lines of machine code given by @macomics, and both resolved to 0x0a. Maybe I am missing something obvious here?
|
||||||||||
12 Jul 2022, 20:50 |
|
revolution 12 Jul 2022, 20:53
macomics wrote: ; 00000010 0f 11 04 0b 83 c1 10 81 f9 a0 00 00 00 72 e3 31 |.............r.1| |
|||
12 Jul 2022, 20:53 |
|
FlierMate1 12 Jul 2022, 20:59
revolution wrote:
Ahh, I found it, so this is it. (Thanks for pointing it out) |
|||
12 Jul 2022, 20:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.