flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Macroinstructions > struc params. Goto page 1, 2 Next | 
| Author | 
 | 
| Roman 27 Apr 2025, 06:13 fasmw 1.73
 Code: struc A p1,p2 { .#p1 dd ? .#p2 dd ? } ptt A x,y ;in code mov [ptt.x],5 ;fasm error undefined ptt.x | |||
|  27 Apr 2025, 06:13 | 
 | 
| macomics 27 Apr 2025, 06:22 Code: struc A p1,p2 { \.#p1 dd ? .#p2 dd ? } ptt A x,y ;in code mov [ptt.x],5 mov [ptty],6 | |||
|  27 Apr 2025, 06:22 | 
 | 
| Roman 27 Apr 2025, 06:26 Thanks. | |||
|  27 Apr 2025, 06:26 | 
 | 
| macomics 27 Apr 2025, 06:50 I'll leave my 15th forum post here. | |||
|  27 Apr 2025, 06:50 | 
 | 
| revolution 27 Apr 2025, 07:16 macomics wrote: I'll leave my 15th forum post here. Quote: Posts: 1111 | |||
|  27 Apr 2025, 07:16 | 
 | 
| Roman 27 Apr 2025, 09:38 Code: struc A [p1] { mov eax,p1 ;fasm error mov [eax],ebx ret \.#p1 dd ? } ;in code ptt A x,y,z mov ebx,5 call ptt.x | |||
|  27 Apr 2025, 09:38 | 
 | 
| macomics 27 Apr 2025, 10:26 Code: struc A [p1] { label \.#p1 mov eax,\.#p1#.var mov [eax],ebx ret \.#p1#.var dd ? } ;in code ptt A x,y,z mov ebx,5 call ptt.x | |||
|  27 Apr 2025, 10:26 | 
 | 
| a 27 Apr 2025, 21:32 revolution wrote: 
 It's obviously an octal. | |||
|  27 Apr 2025, 21:32 | 
 | 
| macomics 28 Apr 2025, 06:03 | |||
|  28 Apr 2025, 06:03 | 
 | 
| Roman 28 Apr 2025, 06:06 Thanks. Very interesting variant.
 I do this variant: Code: struc C [p1] { local ..hh ..hh: dd 0 .#\.#p1 equ ..hh ;variant work equ dword [..hh]. in code mov ptt.y,4 local ..vv .#\.#p1#@ equ ..vv ..vv: mov eax,..hh mov [eax],ebx ret } ;in code ptt C x,y mov ebx,2 call ptt.x@ mov dword [ptt.y],4 Last edited by Roman on 28 Apr 2025, 06:27; edited 3 times in total | |||
|  28 Apr 2025, 06:06 | 
 | 
| macomics 28 Apr 2025, 06:09 Have fun | |||
|  28 Apr 2025, 06:09 | 
 | 
| Roman 28 Apr 2025, 06:13 macomics
 You macro get error. Code: struc A [p1] { forward \.#p1 dd ? forward get@#.#\.#p1: mov eax,\.#p1 mov ebx,[eax] ret forward set@#.#\.#p1: mov eax,\.#p1 mov [eax],ebx ret } jtt A x,y,z ;error undefined get@jtt.x.x in line mov eax,\.#p1 I rewrite your macro: Code: struc A [p1] { \.#p1 dd ? get@#.#\.#p1: mov eax,get@#.#\.#p1-4 ;\.#p1 mov ebx,[eax] ret set@#.#\.#p1: mov eax,set@#.#\.#p1-4 ;\.#p1 mov [eax],ebx ret } Last edited by Roman on 28 Apr 2025, 09:04; edited 3 times in total | |||
|  28 Apr 2025, 06:13 | 
 | 
| macomics 28 Apr 2025, 07:10 It's easy to fix. Just add a struc name to all the labels.
 Code: struc A [p1] { forward .#\.#p1 dd ? forward get@#.#\.#p1: mov eax,.#\.#p1 mov ebx,[eax] ret forward set@#.#\.#p1: mov eax,.#\.#p1 mov [eax],ebx ret } jtt A x,y,z | |||
|  28 Apr 2025, 07:10 | 
 | 
| Roman 28 Apr 2025, 07:15 Thanks. Work fine. | |||
|  28 Apr 2025, 07:15 | 
 | 
| Roman 30 Apr 2025, 05:09 Attached struc to buffer.
 Code: struc G ss,[p1] { common enumm equ 0 forward #.#\.#p1 equ ss+enumm adr@#.#\.#p1: mov eax,ss+enumm ret get@#.#\.#p1: mov eax,ss+enumm mov ebx,[eax] ret set@#.#\.#p1: mov eax,ss+enumm mov [eax],ebx ret enumm equ enumm+4 } section '.code' code writeable executable buf1: .a: dd 8 dup(0) .b: dd 8 dup(0) tu1 G buf1.a,x,y,z tu2 G buf1.b,x,y,z Start: mov ebx,5 call set@tu1.x call adr@tu2.x mov [eax],25 mov dword [tu2.z],7 | |||
|  30 Apr 2025, 05:09 | 
 | 
| Roman 30 Apr 2025, 13:50 How I understood macro and struc similar.
 My question: what special in struc ? And did have struc something special reserved words ? | |||
|  30 Apr 2025, 13:50 | 
 | 
| macomics 30 Apr 2025, 13:56 struc -- allows you to create a macro that will declare instances with a preceding label without a colon, and in this macro there will be an additional reserved word - a dot (the name of this label). Everything else is like in macro.
 Code: use16 macro A { .a db 0 .b db 1 } struc B { .a db 2 .b db 3 } instA: A ; instA A - error instB B ; instB: B - error mov al, [instA.a] mov ah, [instA.b] mov bl, [instB.a] mov bh, [instB.b] Code: $ cat struc_and_macro.asm use16 macro A { .a db 0 .b db 1 } struc B { .a db 2 .b db 3 } instA: A instB B mov al, [instA.a] mov ah, [instA.b] mov bl, [instB.a] mov bh, [instB.b] $ fasm struc_and_macro.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) 1 passes, 19 bytes. $ hexdump -C struc_and_macro.bin 00000000 00 01 02 03 a0 00 00 8a 26 01 00 8a 1e 02 00 8a |........&.......| 00000010 3e 03 00 |>..| Code: 00000000 00 - instA:.a 00000001 01 - instA:.b 00000002 02 - instB.a 00000003 03 - instB.b 00000004 a0 00 00 - mov al, [instA.a] 00000007 8a 26 01 00 - mov ah, [instA.b] 0000000B 8a 1e 02 00 - mov bl, [instB.a] 0000000F 8a 3e 03 00 - mov bl, [instB.a] | |||
|  30 Apr 2025, 13:56 | 
 | 
| Roman 30 Apr 2025, 18:09 Quote: 
 struc can see name instB. This could using for tricky. add B ;mean struc B do add sub B ;mean struc B do sub Code: ;something like this if . eq add display '+;' end if if . eq sub display '-;' end if Last edited by Roman on 30 Apr 2025, 18:32; edited 1 time in total | |||
|  30 Apr 2025, 18:09 | 
 | 
| macomics 30 Apr 2025, 18:20 Code: struc N [A] { forward . eax, A } add N 5, ebx, 10, ecx Code: $ hexdump -C struc_and_macro.bin 00000000 00 01 02 03 a0 00 00 8a 26 01 00 8a 1e 02 00 8a |........&.......| 00000010 3e 03 00 66 83 c0 05 66 01 d8 66 83 c0 0a 66 01 |>..f...f..f...f.| 00000020 c8 |.| Code: 00000013 66 83 c0 05 ; add eax, 5 00000017 66 01 d8 ; add eax, ebx 0000001A 66 83 c0 0a ; add eax, 10 0000001E 66 01 c8 ; add eax, ecx | |||
|  30 Apr 2025, 18:20 | 
 | 
| Goto page 1, 2  Next < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.