flat assembler
Message board for the users of flat assembler.

Index > Programming Language Design > On my new assembler

Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 28 Mar 2015, 18:22
codestar wrote:
What about the "save block/file" feature?
It was not in the initial plan, but it may be added later.

codestar wrote:
As for "`", the option to use `UPPERCASE would be nice to auto-create multiple names and texts from one generic "name": NAME, 'name', ID_NAME, TYPE_NAME, name_fp, name_import, 'NAME.BMP', etc. How about ``name or `+name?
Any advanced source-text processing of this kind should be achievable with EVAL. And it allows to do much more than just that.

codestar wrote:
Is this redefine for both define/equ?

REDEFINE is like a two-liner RESTORE+DEFINE; REEQU is like RESTORE+EQU.

codestar wrote:
Do if/define/equ work the same together?
The EQU is now affected by the IF, but if symbolic variable is used in the arguments to IF, it is still evaluated as an equivalent text of its value.

codestar wrote:
Have you considered a type of "if symbolic" (ifs)?
I considered something like IFDEF/IFNDEF that would work with symbolic variables, because (for the reason mentioned above) the "IF DEFINED" syntax cannot be used with symbols defined by EQU/DEFINE. But this is one of the many potential features that I had not found really necessary, yet.

codestar wrote:
What's this .type/.size applied to macro parameters? Does . (ns.size) have a different meaning?
The "ns" is a parameter and it is replaced with the value of that parameter, which is the name of the parent namespace for the "size" symbol. Note that "." is now a special character - so when "ns" has a value of "@src", "ns.size" becomes simply "@src.size".

codestar wrote:
Is the "esc" a return from macro?
No, it just for the purpose of adding a line to macro body without disturbing the nesting constraints.

codestar wrote:
Any %line, %date, %file/%name tags?
Could be added quite easily. Note that in fasmg I use the rule that built-in symbols with names starting with "$" are the expression-class symbols, while the names starting with "%" always refer to parameters. You can check out the "%t" definition in TABLES.INC for an example.
Post 28 Mar 2015, 18:22
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 28 Mar 2015, 18:41
I have updated the package once again - I decided to switch to version number based on the timestamp.
Post 28 Mar 2015, 18:41
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 28 Mar 2015, 19:41
Tomasz Grysztar wrote:
I have updated the package once again - I decided to switch to version number based on the timestamp.


Tomasz, do you use some version control system? If so, have you thought about publishing the repository? The chance to follow the creation of something good is really interesting and useful.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 28 Mar 2015, 19:41
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 28 Mar 2015, 19:49
JohnFound wrote:
Tomasz, do you use some version control system? If so, have you thought about publishing the repository? The chance to follow the creation of something good is really interesting and useful.
I used the Fossil SCM - I initially wanted to use git, because I already had some experience with it, but after you recommended Fossil I decided to give it a try and I found out that it suits my needs much better. I am undecided about publishing the repository, though.
Post 28 Mar 2015, 19:49
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 28 Mar 2015, 21:02
Tomasz Grysztar wrote:
... but after you recommended Fossil I decided to give it a try...


That is why I asked. Wink It is great, because if there is an existing repository, regardless of your decision in this very moment, there is always a hope it will be published later. Smile

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 28 Mar 2015, 21:02
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 31 Mar 2015, 04:12
For this test program:
Code:
shift = 35
x = (1 shl (1 shl shift)) + 1
display (y and 1) + '0'
y = x shr (1 shl shift)
display y + '0'    
I found the following results with a different value of the "shift" variable:
Code:
shift   result  memory-usage
30      11      ~500MB
31      11      ~1000MB
32      Error: not enough memory to complete the assembly.
33      Error: not enough memory to complete the assembly.
34      Error: not enough memory to complete the assembly.
35      02      ~0.5MB
36      Error: not enough memory to complete the assembly.    
There is a problem when trying to define a 32 gigabit number. Expected result is "11".

I'm using "flat assembler g version 0.90.1427567760"
Post 31 Mar 2015, 04:12
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 31 Mar 2015, 12:52
I updated the package with a related correction.
Post 31 Mar 2015, 12:52
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 03 Apr 2015, 10:00
The .exe file in the 1427806225 download declares itself as "flat assembler g version 0.90.1427567760" but appears to have had the two small changes included. So it is a hybrid new version which pretends it is an older version.
Post 03 Apr 2015, 10:00
View user's profile Send private message Visit poster's website Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 04 Apr 2015, 14:34
Tomasz: Thanks. Would you mind answering a few more questions? Whenever you have time:
Quote:
* No format? Is there a way to specify .EXT in source?
* How to "if x eqtype 0"? Use "if x>=0 & x<=9"?
* How to "if x in <l,i,s,t>"? Use "while ... match x,"? Search with irp?
* How to process [group] arguments?
* Does FASMG have the capability to define a real compiler like C? Almost? C-ish?
* Are {}!? now like standard operators? +-*/
* Example/s of "eval"? I wonder if this will be the solution to the problem of having to resolve partial constant expressions: r1+(W*H*4) = r1+N
In 8086.inc, is this the manual equivalent of "forward push x"? Why "match car= cdr"? Next [x]? Then "else push seq"? Last?
Code:
macro push? sequence
        local seq
        define seq sequence
        while 1
                match car= cdr, seq
                        push car
                        redefine seq cdr
                else
                        push seq
                        break
                end match
        end while
end macro    
Post 04 Apr 2015, 14:34
View user's profile Send private message Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 05 Apr 2015, 17:31
My first try at FASMG. Adam CPU: Assembler + disassembler.
Code:
; ADAM DISASSEMBLER: EXAMPLE.BIN

00000000 $003F nop
00000002 $AA87 go +$00000010
00000004 $0001 mov a1, a2
00000006 $0023 mov ip, a4
00000008 $002E mov bp, sp
0000000A $0800 mov a1, $00000000
0000000C $0805 mov a2, $00000001
0000000E $080B mov a3, $00000004
00000010 $A088 go e, +$00000020
00000012 $0601 mov4 *a1, a2
00000014 $0108 mov1 a2, *a1
00000016 $0701 mov4 *a1, *a2
00000018 $0281 mov1 *a1++, a2
0000001A $0869 mov1 *a3++, $00000001
0000001C $0548 mov4 a2, *a1++
0000001E $07C8 mov4 *a2++, *a1++
00000020 $A18A go ne, +$00000034
00000022 $1341 cmp1 *a1, *a2++
00000024 $2001 add a1, a2
00000026 $3201 sub1 *a1, a2
00000028 $4013 and a3, a4
0000002A $517B or1 sf, *a4++
0000002C $6701 shl4 *a1, *a2
0000002E $7281 shr1 *a1++, a2
00000030 $8548 sar4 a2, *a1++
00000032 $97C8 mul4 *a2++, *a1++
00000034 $0903 mov a4, $00000ABC
00000036 $DABC $data
00000038 $09DB mov4 *a4++, $00CAFE77
0000003A $DCAF $data
0000003C $DE77 $data
0000003E $0A01 mov a1, (a2+$00000ABC)
00000040 $DABC $data
00000042 $0AD3 mov1 *a3, *(a4+$00000123)
00000044 $D123 $data
00000046 $AA09 go -$00000034
00000048 $AAC0 go +$00000ABC
0000004A $D53A $data    
Edit: Sorry for asking questions that you answered on the previous page and/or in the manual. Some editing occurred since I first viewed and downloaded it on my phone. Renamed template from "Atom" to "Adam CPU" (the beginning).


Description: (Adam CPU template. Edited)
Download
Filename: adam.zip
Filesize: 5.58 KB
Downloaded: 814 Time(s)



Last edited by codestar on 07 Apr 2015, 00:48; edited 3 times in total
Post 05 Apr 2015, 17:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 05 Apr 2015, 18:53
codestar wrote:
* No format? Is there a way to specify .EXT in source?
There is just one, plain, output format (others, as in examples, are created through macros) and for this reason I did not implement FORMAT directive yet. I consider adding it just for the purpose of the AS option, though. It would then allow just the "FORMAT BINARY AS 'xxx'" syntax.

codestar wrote:
* How to "if x eqtype 0"? Use "if x>=0 & x<=9"?
The "EQTYPE 0" is able to distinguish the numeric result from the string or floating point, so in some cases it may be used in a way similar to fasm 1.

codestar wrote:
* How to "if x in <l,i,s,t>"? Use "while ... match x,"? Search with irp?
In fasm1 the IN operator was just a shortcut for multiple EQ, and since there is no more EQ in fasmg, the IN went with it. Yes, probably the only option is now to use IRP with either MATCH or with a string comparison (using the ` operator).

codestar wrote:
* How to process [group] arguments?
In the post above where I compared the syntaxes of fasmg and fasm1, I pointed out that in place of parameter grouping, the "&" modifier should be combined with IRP directive. To control the order of processing of the grouped parameters, the INDX directive was added. The usage is very different from the fasm1 FORWARD/REVERSE, but the capabilities are in fact increased this way.

codestar wrote:
* Does FASMG have the capability to define a real compiler like C? Almost? C-ish?
I think it could be possible in theory, though it would probably qualify as an amusement of the same kind as my Brainf* interpreter written in Challenger. By defining a "!" macro, converting all of the lines of source to text, parsing it in VIRTUAL storage and generating new strings for EVAL, you could in theory process even a very complex syntax, though the performance would be terrible. Also you can not use ";" character in syntax, because fasmg removes the comments early during the source tokenization.

codestar wrote:
* Are {}!? now like standard operators? +-*/
Yes, and also the dot. You can used them all as separators in the MATCH pattern.

codestar wrote:
* Example/s of "eval"? I wonder if this will be the solution to the problem of having to resolve partial constant expressions: r1+(W*H*4) = r1+N
I don't know the problem you are referring to - but EVAL is simply just a way of generating a piece of source at the time of assembly, and interpret this fragment of text just as if it was read with INCLUDE from some external file. For example the following source generates the "display x2" line and executes it:
Code:
a1 = 'A'
a2 = 'B'
a3 = 'C'
x = 2

virtual at 0
  db 'display a'
  db '0'+x
  load src : $ from 0
  eval src
end virtual    
The "src" variable contains the string made from the entire contents of VIRTUAL block, then the EVAL simply treats this string as a source and assembles it just like INCLUDE would if the same text was stored in some external file.

codestar wrote:
In 8086.inc, is this the manual equivalent of "forward push x"? Why "match car= cdr"? Next [x]? Then "else push seq"? Last?
This loop serves the role of IRP for the arguments separated with spaces instead of commas. The "match car= cdr" cuts off the first piece that is separated by a whitespace from the rest of sequence. The "else" is executed when there is no more whitespace inside the parameter (so it is the last piece).
Post 05 Apr 2015, 18:53
View user's profile Send private message Visit poster's website Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 09 Apr 2015, 01:32
Wrote some macros today: a[]={1,2,3}, foo(1,a2,&n,a7)
Code:
; process "group arguments"

macro my p&        ; forward
  irp x, p
    display x, ':'
  end irp
end macro

macro my_r p&      ; reverse
  irp x, p
    indx 1+%%-%    ; x=parameter[#]
    display x, ':'
  end irp
end macro

RET equ $D,$A

display RET, '* Result: '

my 'A','B','C','D'
my_r 'A','B','C','D'
display RET

; enumerated constants

macro enum p&
  local n
  n=0
  irp x, p
    match a==b, x
      a=b
      n=b
    else match a, x
      a=n
    else
      err 'Name expected'
    end match
    n=n+1
  end irp
end macro

enum BLACK, GRAY25,\
  GRAY50, GRAY75, WHITE

enum ZERO=0, ONE, TWO,\
  FOUR=4, FIVE, SIX, SEVEN

display '* Constants: '
display TWO+'0', '.', SEVEN+'0'
display '.', WHITE+'0', RET, RET

; create integer variable/s

macro int p&
  irp x, p
    match a==i, x
      display `a, ': dd ', `i
    else match a, x
      display `a, ': dd 0'
    end match
    display RET
  end irp
end macro

macro test_int p&
  display '* Variables: '
  display `p, RET, RET
  int p
end macro

test_int i=7, x, y='Z', n=$CAFEBABE
display RET

; create integer array

; inta array1[8]
; inta array2[]={1,2,3}

macro inta p&
  match a[]=={i}, p
    display `a, ': dd ', `i
  else match a[n], p
    display `a, ': rd ', `n
  else
    err 'Syntax'
  end match
  display RET
end macro

macro test_inta p&
  display '* Array: '
  display `p, RET, RET
  inta p
  display RET
end macro

test_inta array1[8]
test_inta array2[]={1,2,3}

; high-level "call f(...)"

macro hl_call p&
  match name(ps), p
    irp x, ps
     indx 1+%%-% ; x=ps[#]
     match &a, x
       display 'lea a7, ', `a, RET
       display 'push a7', RET
     else match a, x
       display 'push ', `a, RET
     end match
    end irp
    display 'call ', `name, RET
  end match
end macro

macro test_call p&
  display '* Call function: '
  display `p, RET, RET
  hl_call p
end macro

test_call foo(1,2,3,i,&v,a1,a2)    
Post 09 Apr 2015, 01:32
View user's profile Send private message Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 04 May 2015, 14:28
New: Toy Macro Language. Untested.
Code:
; EXAMPLE

include 'toy'

asm 'jmp main'

int i=7, n='Z', j=$CAFEBABE
int array[2]

class POINT
  int x, y
endc

POINT point

function foo
  let eax=point.x, eax+point.y, eax*n
endf

function rgb, r, g, b
  let eax=r, eax<<16,\
    ecx=g, ecx<<8, eax|ecx, eax|b
endf

asm 'main:'
foo
rgb $AA, $BB, $CC    
Function. Any improvements? ("if used..."?). Problems? Parameter names?
Code:
;;;;;;;;;;;;;;;;;;;; FUNCTION ;;;;;;;;;;;;;;;;;;;;

its_name equ 0
its_parameters equ 0
its_locals equ 0

n_parameters=0
parameters_size=0
n_locals=0
locals_size=0

macro function name, p&
  local n
  n=0
  match =0, its_name
    its_name equ name
    its_parameters equ p
  else
    err 'endf expected'
  end match
  n=0
  match any, p
    irp x, p
      n=n+1
    end irp
  end match
  n_parameters=n
  parameters_size=n*4
  @#name:
  asm `name, ':'
  macro name q&
    n=0
    irp x, q
      n=n+1
    end irp
    if n>1
      if n<>n_parameters
        display `name, ': '
        display 'Invalid # parameters', RET
        err ''
      end if
      irp x, q          ; pushr...
        indx 1+%%-%     ; x=q[#]
        asm 'push ', `x
      end irp
    end if
    asm 'call ', `name  ; call f
  end macro
  if n_parameters
    asm 'push ebp'      ; db $55
    asm 'mov ebp, esp'  ; db $89, $E5
    n=8
    irp x, q            ; parameter
      x equ [ebp+n]     ; names
      n=n+4
    end irp
  end if
  scope='f'
end macro

macro return v&
  match any, v
    asm 'mov eax, ', `v
  end match
  if n_parameters \
    | n_locals
    asm 'mov esp, ebp' ; db $89, $EC
    asm 'pop ebp'      ; db $5D
  end if
  if n_parameters
    asm 'ret n'        ; db $C2, dw n
  else
    asm 'ret'          ; db $C3
  end if
end macro

macro endf! v&
  return v
  restore its_name
  irp x, its_parameters
    restore x
  end irp
  scope=0
end macro    


Description:
Download
Filename: toy.zip
Filesize: 2.68 KB
Downloaded: 791 Time(s)

Post 04 May 2015, 14:28
View user's profile Send private message Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 04 May 2015, 22:25
Write PE executable + imports. Standalone .EXE, 1K.
Code:
; EXAMPLE: WRITE EXECUTABLE

@rva equ ($1000-$200)
@base equ ($400000+@rva)

macro align n
  db ((n-1)-($+n-1) mod n) dup(0)
end macro

; example assembler

eax=0
ecx=1
edx=2
ebx=3

macro int3
  db $CC
end macro

macro push_r r
  db $50+r
end macro

macro push_i i
  if i<=$FF
    db $6A, i
  else
    db $68
    dd i
  end if
end macro

macro mov_r32_i r, i
  db $B8+r
  dd i
end macro

macro call_p a
  db $FF, $15
  dd @base+a
end macro

; image size = (section rva+size) rounded to 1000h

image_size_a =\
  ((($1000+one_end-one) shr 12)+1) shl 12

macro write_exe
  dw 'MZ'
  db $3A dup(0)
  dd $40
  db 'PE', 0, 0       ; signature
  dd $1014C, 0, 0, 0  ; cpu (.I386+), # sections, etc
  dd $10F00E0, $10B   ; n/a
  dd 0, 0, 0          ; code/idata/data sizes
  dd $1000, 0, 0      ; entry, code/data offsets
  dd $400000          ; image base
  dd $1000, $200      ; alignment in memory/file
  dd 1, 0, 4, 0       ; versions
  dd image_size_a     ; image size aligned
  dd $200, 0          ; section 1 offset
  dw 2, 0             ; subsystem
  dd $1000, $1000     ; stack/heap
  dd $1000, 0         ; reserve/commit
  dd 0, 16            ; flags, # directories
  dd 0, 0             ; data directories...
  dd it+@rva          ; import table rva, size
  dd exe_end-it
  dq 14 dup(0)
  dq '.one'           ; section
  dd exe_end-one_end  ; size
  dd $1000            ; rva
  dd exe_end-$200     ; size rounded to 200h
  dd $200, 0, 0, 0    ; file offset, etc
  dd $0E0000020       ; attributes: readable, etc
  db $200-$ dup(0)    ; proceed to 200h/1000h
end macro

macro library p&
  irp x, p
    dd 0,0,0, @rva+x#_name, @rva+x#_table
  end irp
  dd 0,0,0,0,0
end macro

macro import name, p&
  name#_name db \     ; text DLL_name='NAME.DLL'
    `name, '.DLL', 0
  name#_table:        ; DLL_table:
  irp x, p
    x dd @rva+_#x     ; import name RVAs
  end irp
  dd 0                ; end
  irp x, p
    _#x dw 0          ; import names
    db `x, 0          ; 'import'
  end irp
end macro

exe:
  write_exe

one:
  mov_r32_i eax, @base+.a
  push_i 0
  push_r eax
  push_r eax
  push_i 0
  call_p MessageBoxA
  push_i 0
  call_p ExitProcess

.a: db 'Windows Example for FASMG', 0

align 16

it:
  library KERNEL32, USER32
  import KERNEL32, ExitProcess
  import USER32, MessageBoxA

one_end:
  align $200
exe_end:    
Post 04 May 2015, 22:25
View user's profile Send private message Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 06 May 2015, 15:31
Intel32 Examples:

One-Byte Instructions
Code:
irp <name,value>,\
  cbw,$98, clc,$F8, cld,$FC, cli,$FA,\
  cmc,$F5, cmpsb,$A6, cmpsd,$A7, cwd,$99,\
  hlt,$F4, int3,$CC, lodsb,$AC, lodsd,$DC,\
  movsb,$A4, movsd,$A5, popf,$9D, pushf,$9C,\
  sahf,$9E, scasb,$AE, scasd,$AF, stc,$F9,\
  std,$FD, sti,$FB, stosb,$AA, stosd,$AB,\
  xlat,$D7
  macro name
    db value
  end macro
end irp

irp <name,value>,\
  aso,$67, lock,$F0, nop,$90, oso,$66,\
  rep,$F3, repne,$F2, wait,$9B
  macro name p&
    db value
    match next, p
      next
    end match
  end macro
end irp    
Branch Conditional
Code:
irp <name,o>,\
  jo,$70, jno,$71, jc,$72, jb,$72,\
  jnae,$72, jnc,$73, jnb,$73, jae,$73,\
  jz,$74, je,$74, jnz,$75, jne,$75,\
  jna,$76, jbe,$76, ja,$77, jnbe,$77,\
  js,$78, jns,$79, jp,$7A, jpe,$7A,\
  jnp,$7B, jpo,$7B, jl,$7C, jnge,$7C,\
  jnl,$7D, jge,$7D, jng,$7E, jle,$7E,\
  jg,$7F, jnle,$7F
  macro name i
    if i<$80 & i>=-$80
      db o, (i-$-1)
    else
      db $0F, (o+$10)
      dd (i-$-4)
    end if
  end macro
end irp    
Is Register?
Code:
numeric al, cl, dl, bl, ah, ch, dh, bh
numeric ax, cx, dx, bx, sp, bp, si, di
numeric eax, ecx, edx, ebx, esp, ebp, esi, edi

macro is_in is, x, p&
  is=0
  irp q, p
    match =x, q
      is=1
      break
    end match
  end irp
end macro

macro if_is x, p&
  local is
  is=0
  is_in is, x, p
  esc if is
end macro

macro is_r is, x
  is=0
  if_is x,\
    al, cl, dl, bl,\
    ah, ch, dh, bh
    is='1'
  else
    if_is x,\
      ax, cx, dx, bx,\
      sp, bp, si, di
      is='2'
    else
      if_is x,\
        eax, ecx, edx, ebx,\
        esp, ebp, esi, edi
        is='4'
      end if
    end if
  end if
end macro    
Should I use the new "element" keyword for this? I would think it would be faster than searching lists. What about "is" in the context of a conditional expression?
Code:
element register 
element r8 : register+1
element r16 : register+2
element r32 : register+3
element eax : r32+0
element ecx : r32+1
element edx : r32+2
; ...
if x is register
  ; ...
end if    
(PS: If there was an optional "iterate" alias for "irp", it would be pure English preprocessing (along with repeat). In most of my code, irp is the only keyword that's not a word in English)

Idea: Extension of `, s/printf style asm 'add eax, ' # ...: Something like this?
Code:
`x     ; quote
``x    ; dequote
`+x    ; uppercase
`-x    ; lowercase
`x%d   ; decimal
`x%h   ; hexadecimal
`x%b   ; binary
`x%d=2 ; alignment...
`x%h=8
`x%b=4    
Code:
asm 'add eax, ' # `n%d
asm 'mov al, ' # `n%h=2 # 'h'
asm 'and cx, ' # `n%b=16 # 'b'    
Without a display/db/put numeric, programmers will have to re-write their own and/or copy them to every new project.

An asm keyword could set current format:
Code:
format asm file       ; write to file (db)
format asm display    ; write to console
format asm virtual p: ; write to memory (p::)    
Post 06 May 2015, 15:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 15 May 2015, 11:37
codestar wrote:
Should I use the new "element" keyword for this? I would think it would be faster than searching lists.
The symbols defined with ELEMENT can serve as a base for relocatable values, and also can be used as variables in linear polynomials. So, for example, if your instruction set may use values like "BX+4" or even "EAX+EBX*2" in arguments, you have to define these symbols with ELEMENT directive so that you can process expressions built around them. On the other hand, if you had an instruction set where BX could only be used as a standalone argument (never inside an expression), simple MATCH could be enough. Still, as you noted, use of ELEMENT could lead to simpler and faster macro than scanning long lists with ELSE MATCH.
Post 15 May 2015, 11:37
View user's profile Send private message Visit poster's website Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 23 May 2015, 16:07
I've been having fun with FASMG lately. Easy to use, definitely an improvement of FASM1.
Quote:
I feel that this project, though a fun thing to play with, consumed way too much of my time recently, a time that maybe would be better spent on implementing AVX512 into fasm
Just relax Cool You don't have to do anything. I've been thinking of the easiest syntax to define instructions which would allow users to upgrade FASM1+G to AVX512+ for you without knowing anything about FASM. Example:
Code:
; inc rm8  ; $FE /0
; inc r32  ; oso $40+r
; inc rm32 ; oso $FF /0

define_opcode_1 inc, 1,\
  rmb=<$FE,/0>, rx=<o,$40+r>, rmx=<o,$FF,/0>    
Think smarter, not harder.
Post 23 May 2015, 16:07
View user's profile Send private message Reply with quote
MIHIP



Joined: 14 Feb 2013
Posts: 130
MIHIP 23 May 2015, 18:27
Hey, Tomasz, you are no longer work at new version of flat assembler? You work at fasm 2.0? Yes?
Post 23 May 2015, 18:27
View user's profile Send private message Visit poster's website Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
codestar 23 May 2015, 23:13
MIHIP: FASM1 is nothing compared to FASMG Smile
Quote:
Please use element
Ok, I'll check it out. Spent 3+ days writing Intel instructions then another 2 days designing a new editor/IDE (Zero-G, see Projects).

For now, my method of searching names works, takes .1 second to compile EXAMPLE.EXE on my MiniX Z64. Notice the optimization: name_length name, n | if n=3. If the name is not exact size, it will not search. All names which are 1 or 4+ characters will be skipped.
Code:
macro name_length name, n
  virtual at 0
    db `name
    n=$
  end virtual
end macro

name_length name, n
if n<>length
  ; do nothing
end if    


Last edited by codestar on 26 May 2015, 07:45; edited 1 time in total
Post 23 May 2015, 23:13
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 24 May 2015, 12:07
Congratulations, Tomasz. Very Happy
Finally you did it, release a first version of fasm g which makes a stone rolling.

Your concept is interesting but the main purpose of assemblers are creating binaries using an instruction set for a specific target processor. Theretically nearly all could be done with macros but with the price of a bad performance and a more or less hard work creating the macros for a specific target.

So - just a proposal to think about:
Wouldn't it be interesting to develop a kind of "instruction definition language" as a specific macro language but with some focus of most used types of statements (instruction, register, address space, size like byte/word/dword/qword) which can be handled faster than interpretation of general purpose macros AND are more easy to define by users ?

As I did implement the Z80 instructions and I think revolution (?) for the ARM processor and you for the main x86 target, wouldn't it be helpful to have an (more or less) easy to use assembly engine which can be adapted to nearly any new processor or microcontroller with minimal work ? So only some basic definitions - if there are instructions to complex they can be generated with the all purpose macro language as well.

This attempt would offer maybe a better speed (at least for the most used instructions) and a wide range of available targets for assembly. The less work necessary for implementing a new target, the more targets you will have at the end for FASM G. I think the reason why you develop this way is, that you doubt there won't be too much assembly programming for x86 systems in the future and the range of upcoming new cpu's, microcontrollers and so on maybe more interesting.

This would be a nice project. Maybe a quite different project than FASM G - but maybe not too much.
Post 24 May 2015, 12:07
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:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.