flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 20 Jun 2025, 06:11
The offset inside "curmacr" must point to the value to read:
Code: format pe section '.code' code writeable executable my_value: curmacr:: db 2 Start: load brr byte from curmacr:my_value display brr+48 ;="2" |
|||
![]() |
|
revolution 20 Jun 2025, 06:20
Note that the original code gives an error, the "0" is just an artefact of the way the assembler works by using zero as a place-holder for all unknown values. So the actual result is a value out of range at offset 0 in the currmac address space. The assembler say exactly that:
Code: flat assembler version 1.73.31 (16384 kilobytes memory) 0 test.asm [8]: Start: load brr byte from curmacr:0 processed: Start:load brr byte from curmacr:0 error: value out of range. |
|||
![]() |
|
Roman 20 Jun 2025, 08:38
this variant not working.
Code: my_value: curmacr:: db 2 macro kk { load tuu byte from curmacr:my_value mov ebp,tuu } kk inc byte [my_value] kk I get two times mov ebp,2 I expected mov ebp,2 and mov ebp,3 Last edited by Roman on 20 Jun 2025, 08:41; edited 2 times in total |
|||
![]() |
|
revolution 20 Jun 2025, 08:46
load is evaluated at assembly time.
inc is evaluated at runtime. Use store to update a value at assembly time. |
|||
![]() |
|
Roman 20 Jun 2025, 08:52
this work.
Code: macro kk v { load tuu byte from curmacr:my_value mov ebp,tuu tuu = tuu+1 store byte tuu at curmacr:my_value } |
|||
![]() |
|
Roman 20 Jun 2025, 08:53
this not work.
|
|||
![]() |
|
revolution 20 Jun 2025, 08:54
Roman wrote: this not work. |
|||
![]() |
|
Roman 20 Jun 2025, 08:58
Shutdown electricy.
Code: macro a0 { inc eax } macro a1 { dec eax } macro a2 { sub eax,10 } macro kk v { load tuu byte from curmacr:my_value a\#\tuu ;fasm error mov ebp,tuu tuu = tuu+1 store byte tuu at curmacr:my_value } Last edited by Roman on 20 Jun 2025, 09:01; edited 1 time in total |
|||
![]() |
|
revolution 20 Jun 2025, 09:00
tuu is a variable, not an equ. So that can never work.
Use if ... else ... end if. Code: if tuu = 0 a0 else if tuu = 1 ... Last edited by revolution on 20 Jun 2025, 09:02; edited 1 time in total |
|||
![]() |
|
Roman 20 Jun 2025, 09:02
Its bad news for me.
|
|||
![]() |
|
revolution 20 Jun 2025, 09:03
This is the same problem again. Mixing assembler with the preprocessor.
|
|||
![]() |
|
Roman 20 Jun 2025, 09:15
Quote:
sometimes its needed. |
|||
![]() |
|
revolution 20 Jun 2025, 09:17
It is really just a matter of choosing to use either the preprocessor or the assembler, but not both together.
It is, of course, possible to use both together, but often is causes much confusion, so I recommend to not do it without a full understanding of everything involved. The code above could be written to use the preprocessor completely (no load, store, if, etc.), or it could be written to be all assembler (with load, store, if, else, end. etc.). |
|||
![]() |
|
Tomasz Grysztar 20 Jun 2025, 10:22
Roman wrote:
|
|||
![]() |
|
Roman 20 Jun 2025, 10:47
Quote: And that's why I needed to make a new engine (fasmg) for fasm 2. The first one is stuck with its preprocessor separation. https://board.flatassembler.net/topic.php?t=23831 This is important accent! And main goal! And show main difference between fasm1 and fasmg. I study fasm1 15 years. And today I found out about main difference between fasm1 and fasmg. |
|||
![]() |
|
revolution 20 Jun 2025, 11:56
Regarding the topic title: Address space identifiers reference the address space, and not the offset within the space. For example the following uses four address space identifiers, and the output shows that all four identifiers end up being the same thing. A single address space identifier can be placed anywhere within the space and it will reference the entire space.
Code: virtual at 0x12345678 address_space_identifier_0:: var0 db '0' address_space_identifier_1:: var1 db '1' address_space_identifier_2:: var2 db '2' address_space_identifier_3:: end virtual load v00 from address_space_identifier_0:var0 load v01 from address_space_identifier_0:var1 load v02 from address_space_identifier_0:var2 load v10 from address_space_identifier_1:var0 load v11 from address_space_identifier_1:var1 load v12 from address_space_identifier_1:var2 load v20 from address_space_identifier_2:var0 load v21 from address_space_identifier_2:var1 load v22 from address_space_identifier_2:var2 display v00, v01, v02, v10, v11, v12, v20, v21, v22 Code: flat assembler version 1.73.31 (16384 kilobytes memory) 012012012 1 passes, 0 bytes. |
|||
![]() |
|
Roman 20 Jun 2025, 12:05
Quote:
get '012'. Very unusual logic. expected in address_space_identifier_2 only var2 |
|||
![]() |
|
revolution 20 Jun 2025, 12:12
I forgot to include the final identifier:
Code: ... load v30 from address_space_identifier_3:var0 load v31 from address_space_identifier_3:var1 load v32 from address_space_identifier_3:var2 display v00, v01, v02, v10, v11, v12, v20, v21, v22, v30, v31, v32 Code: flat assembler version 1.73.31 (16384 kilobytes memory) 012012012012 1 passes, 0 bytes. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.