flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > About postpone |
Author |
|
macomics 09 Apr 2023, 12:38
Code: postpone { display '1', 13, 10 } conn db 1 postpone { display '2', 13, 10 } postpone { display '3', 13, 10 ponn = '0' } display ponn, 13, 10 postpone { display '4', 13, 10} Code: $ fasm -m 1024 main.asm flat assembler version 1.73.30 (1024 kilobytes memory) 0 1 2 3 4 2 passes, 1 bytes. $ hexdump -C main.bin 00000000 01 |.| 00000001 |
|||
09 Apr 2023, 12:38 |
|
revolution 09 Apr 2023, 12:44
You can't forward reference in the preprocessor.
Since all postpone blocks are placed at the end, then anything in them must allow forward referencing, or it won't work. |
|||
09 Apr 2023, 12:44 |
|
macomics 09 Apr 2023, 14:27
Code: postpone { display '1', 13, 10 } conn db 1 postpone { display '2', 13, 10 } display ponn, 13, 10 ; forward reference postpone { display '3', 13, 10 ponn = '0' } ; once assigned postpone { display '4', 13, 10} Code: $ fasm -m 1024 main.asm flat assembler version 1.73.30 (1024 kilobytes memory) 0 1 2 3 4 2 passes, 1 bytes. $ hexdump -C main.bin 00000000 01 |.| 00000001 |
|||
09 Apr 2023, 14:27 |
|
Roman 09 Apr 2023, 15:04
Interesting this.
Code: define cii iipp1 cii equ iipp2 cii equ [esi+iipp3] irpv v,cii { mov eax,v display 'pon;;',13,10 } postpone { iipp1 = 1 ;this work without postpone too for irpv. iipp2 = 2 iipp3 = 8 } Last edited by Roman on 09 Apr 2023, 16:22; edited 2 times in total |
|||
09 Apr 2023, 15:04 |
|
revolution 09 Apr 2023, 15:15
Sorry, I'll try to be more clear.
You can forward reference in the assembler, so using "=" works fine. The assembler is multi-pass. You can't forward reference in the preprocessor. So "equ", "define", etc. can't be forward referenced. The preprocessor is single-pass. |
|||
09 Apr 2023, 15:15 |
|
Roman 09 Apr 2023, 19:41
https://github.com/tgrysztar/fasm/blob/master/FASM.TXT?ysclid=lg9sw0tcgl458992975#L4342
Quote:
Cool , but I'm confused and don't understand why it's useful and when it's necessary ? Quote: will get automatically And why is profitable, do this in the end of source ? Code: mov eax,pponn ;ida pro show mov eax,11 , but absent inc edi postpone { pponn = counn inc edi ;this ignored or put in another place ? } counn = 11 |
|||
09 Apr 2023, 19:41 |
|
bitRAKE 09 Apr 2023, 21:16
Do you ever create a resource you want to clean up later? Sometimes we don't know when is later. So, we can setup for cleanup later - whenever that is. This could be the finalization of a symbol based on prior work - this is rather common.
Code: tally = 0 postpone { TOTAL = tally } macro bit_gravy count { tally = tally + count } ; we don't know how many bits are needed ; (imagine many consumers) bit_gravy 23 bit_gravy 11 bit_gravy 71 rb (TOTAL+7) shr 3 ; enough space dynamically |
|||
09 Apr 2023, 21:16 |
|
macomics 09 Apr 2023, 21:42
Code: macro proc name, [args] { name: postpone \{ if definite name#.stackFrame name#.stackFrameSize = name#.stackFrame end if \} ... macro invoke name, args& { ... call name if ~ args eq if .count <> 0 & name#.stackFrame < .count name#.stackFrame = .count ... end if .count = 0 end if P.S. This is an example of my macros that I use. In standard macros, the same operation is calculated in the end macro. |
|||
09 Apr 2023, 21:42 |
|
Roman 10 Apr 2023, 04:08
BitRake
Code: tally = 0 postpone { TOTAL = tally } macro bit_gravy count { tally = tally + count } ; we don't know how many bits are needed ; (imagine many consumers) bit_gravy 23 bit_gravy 11 bit_gravy 71 rb (TOTAL+7) shr 3 ;why not used this? Without postpone rb (tally+7) shr 3 |
|||
10 Apr 2023, 04:08 |
|
bitRAKE 10 Apr 2023, 05:10
Roman, We can always unwrap macros and just list the instructions we want to use. Why use any macro? Think about it this way then:
Code: postpone { purge bit_gravy ; no more gravy Gravy db (tally+7) shr 3 ; enough space dynamically } tally = 0 macro bit_gravy count { tally = tally + count } Not all abstractions are [always] useful. There are also some good examples in the fasm package - have you looked at those? _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Apr 2023, 05:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.