flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Tomasz Grysztar
To account for all the key features of "struct" it would have to look like this:
Code: struc @Header next,data_fullscan,prev_flag { .NEXT dd next+0 .DataFullScan dw data_fullscan+0 virtual at .DataFullScan .IDLE_CODE db ? .NUMB_LABEL dw ? .ADDR_LLT dd ? .SCAN_SP dd ? .NESTING dw ? .substr_end = $-$$ end virtual if .substr_end>$-.DataFullScan rb .substr_end-($-.DataFullScan) end if .PREV_FLAG dw prev_flag+0 } virtual at 0 @Header @Header sizeof.@Header = $ end virtual |
|||
![]() |
|
ouadji
thank you very much Tomasz. it works fine. the full_struc for me is : Code: ;WINK_SEGMENT_HEADER_LENGTH struc @Header next,prev_addr,nb_char,reserved_,data_fullscan,\ prev_flag,free_db,free_dd { .NEXT dd next+0 .PREV_ADDR dd prev_addr+0 .NB_CHAR dd nb_char+0 .RESERVED_ dd reserved_+0 .Data_FullScan dw data_fullscan+0 virtual at .Data_FullScan .IDLE_CODE db ? .PROC_LABEL dw ? .ENDP__ dw ? .NUMB_LABEL dw ? .ADDR_LLT dd ? .SCAN_SP dd ? .NESTING dw ? .INDEX_PROC dd ? .FREE___ dd ? .substr_end = $-$$ end virtual if .substr_end>$-.Data_FullScan rb .substr_end-($-.Data_FullScan) end if .PREV_FLAG dw prev_flag+0 .FREE_DB db free_db+0 .FREE_DD dd free_dd+0 } virtual at 0 @Header @Header sizeof.@Header = $ end virtual but : A) why "+0" ?? B) Why is it necessary to add this: Code: virtual at 0 @Header @Header sizeof.@Header = $ end virtual To be allowed to do, for example : mov eax,[eax+ @Header.Data_FullScan] Why my code does not compile without that ? C) why this : Code: if .substr_end>$-.Data_FullScan rb .substr_end-($-.Data_FullScan) end if and not only this : " rb .substr_end " and nothing else. EDIT: (about "C") ok,i understood !!! ![]() IF "virtual/end virtual" > .Data_FullScan dw THEN rb x Last edited by ouadji on 08 Oct 2010, 19:49; edited 1 time in total |
|||
![]() |
|
baldr
ouadji,
A) dw prev_flag+0 is a cute shortcut for Code: if prev_flag eq
dw 0
else
dw prev_flag
end if |
|||
![]() |
|
ouadji
Code:
if prev_flag eq
dw 0
else
dw prev_flag
end i
thank you baldr, but i don't understand. ![]() Code: if prev_flag eq ;(nothing i guess) .PREV_FLAG dw 0 else .PREV_FLAG dw prev_flag wat's the difference between "dw 0" and " dw prev_flag" (in the case of this 'struct') |
|||
![]() |
|
baldr
ouadji,
With this trick empty argument means 0 (+0, to be exact ![]() |
|||
![]() |
|
ouadji
ok. YY dd X±y if X = no_thing then X = no_thing ± y = ±y (here '+y' with y=0) else X = y ± the_thing ![]() I guess that "?" doesn't exist with "struc" (like with "struct") ok, this allows to initialize each field ... in the absence of direct initialization |
|||
![]() |
|
Tomasz Grysztar
baldr wrote: B) Another way to define sizeof.struct is to sum sizeofs of its fields, but with regard of alignment and nested structs / unions this task might be quite a challenge; much easier is to define an instance and measure its size. ouadji wrote: I guess that "?" doesn't exist with "struc" Code: if next in <,?> .NEXT dd ? else .NEXT dd next end if |
|||
![]() |
|
baldr
ouadji,
That was (IIRC) trick from the pre-eq era, remnants can be seen in INCLUDE\MACRO\RESOURCE.INC still. As you may expect, «-0» works the same way (since +/- have lowest precedence). To detect (and use «?» instead of) empty macro argument, eq operator had to be devised. struc-macro is a macro of special behavior, in all other aspects it is exactly macro. So are instant macros like rept, irp or even so powerful match. ![]() Anyway, you may preprocess your source and see what develops. ----8<---- Tomasz Grysztar, Those are related, aren't they? I was emphasizing on the most apparent effect. Thanks for correction, though. |
|||
![]() |
|
ouadji
Code: struc @Header ;nothing else here { .NEXT dd ? .PREV_ADDR dd ? .NB_CHAR dd ? ; "?" for all. (thank you Tomasz/baldr for your reply) indeed, "?" exists with "struc" like with "struct". this above does compile without any problem. |
|||
![]() |
|
Tomasz Grysztar
baldr wrote: That was (IIRC) trick from the pre-eq era, remnants can be seen in INCLUDE\MACRO\RESOURCE.INC still. baldr wrote: Those are related, aren't they? I was emphasizing on the most apparent effect. Thanks for correction, though. |
|||
![]() |
|
ouadji
Quote:
|
|||
![]() |
|
bitRAKE
I like to use STRUC with VIRTUAL block instead of offsets because a change in base register results in a single place to change code. Also, the code seems more appealing to me. Of course, the use of offsets is more literal - matching the addressing being used.
Oh, notice the rbp+rcx*.tmp.. ![]() Code: struc Temp { .a db ? .b db ? .. = $ - .a } virtual at rbp+rcx*.tmp.. .tmp Temp end virtual mov al,[.tmp.a] sub al,[.tmp.b] |
|||
![]() |
|
ouadji
Code: mov al,[rbp+(rcx*2)] sub al,[rbp+(rcx*2)+1] I personally don't like this approach. This is powerful, I agree with you, but it removes any possibility of understanding the code directly by reading it. for me it's rather a way of complicating the code rather than simplified it. Quote: Also, the code seems more appealing to me. ![]() macros addict ? ![]() |
|||
![]() |
|
bitRAKE
Quote: it removes any possibility of understanding the code directly by reading it. ![]() So, you'd rather look at a long string of instructions with a small variation? Do you stare at the sidewalk as you stroll through the park? I'm not the one using PROC/ENDP/STRUCT - I like the FASM language and use it - rather than an adapter layer for those familiar with another assembler. Seems we are coders of a similar nature really. |
|||
![]() |
|
ouadji
I live in the woods, no cars, no traffic here, ... and no sidewalks ! it's paradise here ! Last edited by ouadji on 12 Oct 2010, 12:23; edited 5 times in total |
|||
![]() |
|
edfed
ouadji wrote:
i dont find it hard to understand. it takes the byte at ebp +ecx*2, and sub the byte at ebp+ecx*2+1. it is not very hard to understand... |
|||
![]() |
|
3200th
edfed wrote: i dont find it hard to understand. ![]() |
|||
![]() |
|
ouadji
Quote:
![]() how old am i ? ![]() that said, it's true that this : Code: struc Temp { .a db ? .b db ? .. = $ - .a } virtual at rbp+rcx*.tmp.. .tmp Temp end virtual mov al,[.tmp.a] sub al,[.tmp.b] Code: mov al,[rbp+(rcx*2)] sub al,[rbp+(rcx*2)+1] ![]() |
|||
![]() |
|
3200th
ouadji wrote: how old am i ? ![]() ![]() |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.