flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > fasm1 assemble.inc

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 325
Location: Russian Federation, Sochi
in reserve data directives
Code:
zero_words:
        xor     eax,eax
        jmp     bytes_stosb_ok    


Code:
zero_dwords:
        xor     eax,eax
        jmp     bytes_stosw_ok    


will be couple bytes shorter. or they repeat logic each other for readability?

in defining data directives:
define_data - responsible for handling dup cases only?

what memory looks like on entry of data definition macros?
Code:
data_bytes:
        call    define_data
        jc      instruction_assembled
        lods    byte [esi]
        cmp     al,'('
        je      get_byte
        cmp     al,'?'    

(what full content pointed with esi in next cases)

cases:
Code:
db 0 dup (?)
db 5 dup 5,6
db 5 dup (5,6)
db ""
db "Hello"
dw "ab"13,10
du "ab",13,10
dp 6000
dp 100:100
dd 6000
dd 100:100
dq "Hello"
dt 1.0
dt 1f
dt 1e4

rb 2    


Why I goes there: I interest in way how to add [index] to data directives as marker of allowing them to be set with sequence against single value. in core or in macro.
I tryed to goes from equatinII where structures were defined crossbit x86 x86-64 (realized via macroed data directives VOID,ptr,HNDL that chnge its size according to bitness) to form where they will be crossarchitecture not only crossbit (so all native to fasm data directives is become unconviniet (except db), they all replaced to VOID_ with defined suffix of bit size of data). I can attach package (current state https://yadi.sk/d/0Iq-Lmb6VzNWvQ is inconsistent most of all sorces require old includes, but even structure of includes became more complicated, structs and equates separated etc.) I tryed to friend fasmarm includes and fasm includes, like previously done that with fasm & fasmg (at past time I split includes for fasm & fasmg into 2 folders, but in this case I would like to mix them in same include root folder.

wanted ( VOID_8 synonym of db, not db itself): db[] "" -valid, db "" - not, db[4] 1,"cat" - valid, db[4] "Hello" - not. in fasmg something similar was realized by macro... not error creating according to indexes, but indexes itself realized.

fittest itself is ready in form of macro
Code:
macro fittest name,[arg] {
  virtual at -sizeof.#name
    name arg
    if $
      display "mismatch size of directive &",13,10,"size of args"
      error
    end if
  end virtual }    


but splitting arg for index part and truly arg part became hard.
indexes could be set of combination of [] or [integer] - needed endless cicle in preprocessor time that breaked with condition.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 24 Jan 2019, 08:11; edited 4 times in total
Post 23 Jan 2019, 15:30
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 325
Location: Russian Federation, Sochi
I hope fas file help...
Code:
fas_header      struc ;
signature       db ?,?,?,?                    ; string(4)
fasm_version    db ?,?                    ; base 10
hdr_length      dw ?                    ; offset fas_header
off_input       dd ?                    ; offset
off_output      dd ?
str_tbl         dd ?
str_tbl.length  dd ?
sym_tbl         dd ?
sym_tbl.length  dd ?
preproc_src     dd ?                    ; offset (00000000)
preproc_src.length dd ?
assembly_dump   dd ?                    ; offset (00000000)
assembly_dump.length dd ?
sec_name_tbl    dd ?
sec_name_tbl.length dd ?
sym_ref_dump    dd ?
sym_ref_dump.length dd ?
fas_header      ends

; ---------------------------------------------------------------------------

_linenumber     union ; (sizeof=0x4, mappedto_5) ; XREF: preproc_line/r
                                        ; assembly_dump_row/r
field_0         dd ?                    ; enum linenumber
field_1         dd ?                    ; base 10
_linenumber     ends

; ---------------------------------------------------------------------------

preproc_line    struc ; (sizeof=0x10, mappedto_2) ; XREF: preproc_src:stru_66/r
                                        ; preproc_src:00000088/r ...
source          dd ?
field_4         _linenumber ?
field_8         dd ?
field_C         dd ?
preproc_line    ends

; ---------------------------------------------------------------------------

assembly_dump_row struc ; (sizeof=0x1C, mappedto_6) ; XREF: assembly_dump:stru_262/r
                                        ; assembly_dump:0000027E/r ...
output_offs     dd ?
preproc_src_line_offs dd ?
value_of_$      dd ?
value_of_$.high dd ?
extSIB          dd ?
field_10        _linenumber ?
type_of_$_addr  db ?
type_of_code    db ?                    ; base 10
isinvirtual     db ?
value_of_$.high_used db ?
assembly_dump_row ends

; ---------------------------------------------------------------------------

; enum linenumber, mappedto_3, bitfield
linenumber_0     = 0
from_src         = 0
from_macro       = 80000000h

;
; +-------------------------------------------------------------------------+
; |   This file has been generated by The Interactive Disassembler (IDA)    |
; |           Copyright (c) 2015 Hex-Rays, <support@hex-rays.com>           |
; |                      License info: 48-B611-7234-BB                      |
; |             Doskey Lee, Kingsoft Internet Security Software             |
; +-------------------------------------------------------------------------+
;
; Input MD5   : 7744436A86CBFD06AFCDEC439537D78E
; Input CRC32 : 49986517

; File Name   : C:\FASM\TEST\2.fas
; Format      : Binary file
; Base Address: 0000h Range: 0000h - 0426h Loaded length: 0426h

                .686p
                .mmx
                .model flat

; ===========================================================================

; Segment type: Pure code
seg000          segment byte public 'CODE' use32
                assume cs:seg000
                assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing
aFas            db 'fas',1Ah            ; signature
                db 1, 73                ; fasm_version
                dw sizeof.fas_header    ; hdr_length
                dd input_name-str_tbl   ; off_input
                dd output_name-str_tbl  ; off_output
                dd str_tbl              ; str_tbl
                dd 26h                  ; str_tbl.length
                dd offset stru_66       ; sym_tbl
                dd 0                    ; sym_tbl.length
                dd offset stru_66       ; preproc_src
                dd 1FCh                 ; preproc_src.length
                dd offset stru_262      ; assembly_dump
                dd 1C4h                 ; assembly_dump.length
                dd end                  ; sec_name_tbl
                dd 0                    ; sec_name_tbl.length
                dd end                  ; sym_ref_dump
                dd 0                    ; sym_ref_dump.length
seg000          ends

; ===========================================================================

; Segment type: Regular
str_tbl         segment byte public '' use32
                assume cs:str_tbl
                ;org 40h
                assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing
input_name      db 'C:\FASM\TEST\2.ASM',0
output_name     db 'C:\FASM\TEST\2.BIN',0
str_tbl         ends

; ===========================================================================

; Segment type: Regular
preproc_src     segment byte public '' use32
                assume cs:preproc_src
                ;org 66h
                assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing
prep_line1      preproc_line <0, <1 or from_src>, 0, 0> ; DATA XREF: seg000:aFaso
                db 26, 2, 'db'
                db 26, 1, '0'
                db 26, 3, 'dup'
                db '('
                db 26, 1, '?'
                db ')'
                db 0
prep_line2      preproc_line <0, <2 or from_src>, 0Eh, 0>
                db 26, 2, 'db'
                db 26, 1, '5'
                db 26, 3, 'dup'
                db 26, 1, '5,'
                db 26, 1, '6'
                db 0
prep_line3      preproc_line <0, <3 or from_src>, 1Ch, 0>
                db 26, 2, 'db'
                db 26, 1, '5'
                db 26, 3, 'dup'
                db '('
                db 26, 1, '5'
                db ','
                db 26, 1, '6'
                db ')'
                db 0
prep_line4      preproc_line <0, <4 or from_src>, 2Ch, 0>
                db 26, 2, 'db'
                db '"'
                dd 0
                db 0
prep_line5      preproc_line <0, <5 or from_src>, 33h, 0>
                db 26, 2, 'db'
                db '"'
                dd 5
aHello          db 'Hello'
                db 0
prep_line6      preproc_line <0, <6 or from_src>, 3Fh, 0>
                db 26, 2, 'dw'
                db '"'
                dd 2
aAb             db 'ab'
                db ','
                db 26, 2, '13'
                db ','
                db 26, 2, '10'
                db 0
prep_line7      preproc_line <0, <7 or from_src>, 4Eh, 0>
                db 26, 2, 'du'
                db '"'
                dd 2
aAb_0           db 'ab'
                db ','
                db 26, 2, '13'
                db ','
                db 26, 2, '10'
                db 0
prep_line8      preproc_line <0, <8 or from_src>, 5Dh, 0>
                db 26, 2, 'dp'
                db 26, 4, '6000'
                db 0
prep_line9      preproc_line <0, <9 or from_src>, 66h, 0>
                db 26, 2, 'dp'
                db 26, 3, '100'
                db ':'
                db 26, 3, '100'
                db 0
prep_line10     preproc_line <0, <0Ah or from_src>, 72h, 0>
                db 26, 2, 'dd'
                db 26, 4, '6000'
                db 0
prep_line11     preproc_line <0, <0Bh or from_src>, 7Bh, 0>
                db 26, 2, 'dd'
                db 26, 3, '100'
                db ':'
                db 26, 3, '100'
                db 0
prep_line12     preproc_line <0, <0Ch or from_src>, 87h, 0>
                db 26, 2, 'dq'
                db '"'
                dd 5
aHello_0        db 'Hello'
                db 0
prep_line13     preproc_line <0, <0Dh or from_src>, 93h, 0>
                db 26, 2, 'dt'
                db 26, 3, '1.0'
                db 0
prep_line14     preproc_line <0, <0Eh or from_src>, 9Bh, 0>
                db 26, 2, 'dt'
                db 26, 2, '1f'
                db 0
prep_line15     preproc_line <0, <0Fh or from_src>, 0A2h, 0>
                db 26, 2, 'dt'
                db 26, 3, '1e4'
                db 0
prep_line16     preproc_line <0, <10h or from_src>, 0AAh, 0>
                db 0
prep_line17     preproc_line <0, <11h or from_src>, 0ACh, 0>
                db 26, 2, 'rb'
                db 26, 1, '2'
                db 0
preproc_src     ends

; ===========================================================================

; Segment type: Regular
assembly_dump   segment byte public '' use32
                assume cs:assembly_dump
                ;org 262h
                assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing
stru_262        assembly_dump_row <0, prep_line1-preproc_src, 0, 0, 0, <0>, 0, 16, 0, 0>
                                        ; DATA XREF: seg000:aFaso
                assembly_dump_row <0, prep_line2-preproc_src, 0, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <6, prep_line3-preproc_src, 6, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <10h, prep_line4-preproc_src, 10h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <10h, prep_line5-preproc_src, 10h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <15h, prep_line6-preproc_src, 15h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <1Bh, prep_line7-preproc_src, 1Bh, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <23h, prep_line8-preproc_src, 23h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <29h, prep_line9-preproc_src, 29h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <2Fh, prep_line10-preproc_src, 2Fh, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <33h, prep_line11-preproc_src, 33h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <37h, prep_line12-preproc_src, 37h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <3Fh, prep_line13-preproc_src, 3Fh, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <49h, prep_line14-preproc_src, 49h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <53h, prep_line15-preproc_src, 53h, 0, 0, <0>, 0, 16, 0, 0>
                assembly_dump_row <5Dh, prep_line17-preproc_src, 5Dh, 0, 0, <0>, 0, 16, 0, 0>
                dd  5Dh
assembly_dump   ends


                end:       

but is not - I cant see after db ( and in case of dt can`t see . after this (
for data definition testing:
Code:
...

        lods    byte [esi]
        cmp     al,'('
        je      get_byte; or get other specific to data
        cmp     al,'?'    
...    
Post 24 Jan 2019, 05:54
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.