flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > FASMARM v1.43 - Cross assembler for ARM CPUs

Goto page Previous  1, 2, 3 ... 24, 25, 26 ... 30, 31, 32  Next
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Picnic wrote:
Any plans for high-level control structures such as IF, WHILE, REPEAT, etc ?
Not sure what you are asking. fasmarm already supports all the same fasm style if, while, repeat, etc.
Post 16 Mar 2015, 12:19
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Oh, sorry my bad, i'm refering to directives such as .if .while .repeat etc.

Code:
   .while r0

   .endw
    


Last edited by Picnic on 16 Mar 2015, 12:45; edited 1 time in total
Post 16 Mar 2015, 12:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Those are not assembler directives. They are macros defined by IF.INC. If you want to use those in fasmarm then some changes would be necessary to account for the different instruction and register sets.
Post 16 Mar 2015, 12:42
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
I know, just wondering so. I was hoping for some 'official' changes. It would be a nice add on for lazy programmers such myself. Razz

Well, as fasmarm becomes more popular every day you will have such requests more often.

Nevertheless, a great job fasmarm is.
Post 16 Mar 2015, 12:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
I made a quick untested edit. Let me know if it blows up.
Code:
; Macroinstructions for HLL-style conditional operations

macro .if [arg]
{
  common
  __IF equ
  local ..endif
  __ENDIF equ ..endif
  local ..else
  __ELSE equ ..else
  BNCOND __ELSE,arg
}

macro .else
{
  b __ENDIF
  __ELSE:
  restore __IF
  __IF equ ,
}

macro .elseif [arg]
{
  common
  b __ENDIF
  __ELSE:
  restore __ELSE
  local ..else
  __ELSE equ ..else
  BNCOND __ELSE,arg
}

macro .endif
{
  if __IF eq
   __ELSE:
  end if
  __ENDIF:
  restore __ELSE
  restore __ENDIF
  restore __IF
}

macro .while [arg]
{
  common
  local ..while
  __WHILE equ ..while
  local ..endw
  __ENDW equ ..endw
  __WHILE:
  BNCOND __ENDW,arg
}

macro .endw
{
  b __WHILE
  __ENDW:
  restore __ENDW
  restore __WHILE
}

macro .repeat
{
  local ..repeat
  __REPEAT equ ..repeat
  __REPEAT:
}

macro .until [arg]
{
  common
  BNCOND __REPEAT,arg
  restore __REPEAT
}

bneq equ bne
bnne equ beq
bncs equ bcc
bncc equ bcs
bnmi equ bpl
bnpl equ bmi
bnvs equ bvc
bnvc equ bvs
bnhi equ bls
bnls equ bhi
bnge equ blt
bnlt equ bge
bngt equ ble
bnle equ bgt
bnhs equ blo
bnlo equ bhs

macro BNCOND label,v1,c,v2
{
 match any,c
 \{
   cmp v1,v2
   bn\#c label
 \}
 match ,c
 \{
   PARSECOND parsed@cond,v1
   match cond,parsed@cond \\{ BNCONDEXPR label,cond \\}
 \}
}

gt equ >
lt equ <

macro PARSECOND parsed,cond
{
 define parsed
 define neg@cond
 define status@cond
 define nest@cond
 irps symb,cond
 \{
   define symb@cond symb
   match >,symb
   \\{
      define symb@cond gt
   \\}
   match <,symb
   \\{
      define symb@cond lt
   \\}
   current@cond equ status@cond
   match ,current@cond
   \\{
      match ~,symb
      \\\{
          neg@cond equ neg@cond ~
          match ~~,neg@cond
          \\\\{
               define neg@cond
          \\\\}
          define symb@cond
      \\\}
      match (,symb
      \\\{
          parsed equ parsed neg@cond,<
          define nest@cond +
          define symb@cond
          define neg@cond
      \\\}
      match any,symb@cond
      \\\{
          parsed equ parsed neg@cond,symb@cond
          define status@cond +
      \\\}
   \\}
   match status,current@cond
   \\{
      match &,symb
      \\\{
          parsed equ parsed,&,
          define status@cond
          define symb@cond
          define neg@cond
      \\\}
      match |,symb
      \\\{
          parsed equ parsed,|,
          define status@cond
          define symb@cond
          define neg@cond
      \\\}
      match (,symb
      \\\{
          define nest@cond (
      \\\}
      match ),symb
      \\\{
          match +,nest@cond
          \\\\{
               parsed equ parsed>
               define symb@cond
          \\\\}
          restore nest@cond
      \\\}
      match any,symb@cond
      \\\{
          parsed equ parsed symb@cond
      \\\}
   \\}
 \}
}

macro define_BNCONDEXPR
{
 macro BNCONDEXPR elabel,[mod,cond,op]
 \{
  \common
   \local ..t,..f
   define t@cond ..t
   define f@cond ..f
  \forward
   match ,op
   \\{
      match ,mod \\\{ BNCONDEL elabel,<cond> \\\}
      match ~,mod \\\{ BCONDEL elabel,<cond> \\\}
   \\}
   match &:flabel:tlabel, op:f@cond:t@cond
   \\{
      match ,mod \\\{ BNCONDEL flabel,<cond> \\\}
      match ~,mod \\\{ BCONDEL flabel,<cond> \\\}
      tlabel:
      \\local ..tnew
      restore t@cond
      define t@cond ..tnew
   \\}
   match |:flabel:tlabel, op:f@cond:t@cond
   \\{
      match ,mod \\\{ BCONDEL tlabel,<cond> \\\}
      match ~,mod \\\{ BNCONDEL tlabel,<cond> \\\}
      flabel:
      \\local ..fnew
      restore f@cond
      define f@cond ..fnew
   \\}
  \common
   label f@cond at elabel
   t@cond:
   restore t@cond
   restore f@cond
 \}
}

macro define_BCONDEXPR
{
 macro BCONDEXPR elabel,[mod,cond,op]
 \{
  \common
   \local ..t,..f
   define t@cond ..t
   define f@cond ..f
  \forward
   match ,op
   \\{
      match ,mod \\\{ BCONDEL elabel,<cond> \\\}
      match ~,mod \\\{ BNCONDEL elabel,<cond> \\\}
   \\}
   match |:flabel:tlabel, op:f@cond:t@cond
   \\{
      match ,mod \\\{ BCONDEL flabel,<cond> \\\}
      match ~,mod \\\{ BNCONDEL flabel,<cond> \\\}
      tlabel:
      \\local ..tnew
      restore t@cond
      define t@cond ..tnew
   \\}
   match &:flabel:tlabel, op:f@cond:t@cond
   \\{
      match ,mod \\\{ BNCONDEL tlabel,<cond> \\\}
      match ~,mod \\\{ BCONDEL tlabel,<cond> \\\}
      flabel:
      \\local ..fnew
      restore f@cond
      define f@cond ..fnew
   \\}
  \common
   label f@cond at elabel
   t@cond:
   restore t@cond
   restore f@cond
 \}
}

macro define_BNCONDEL
{
 macro BNCONDEL label,cond
 \{
   \local COND
   match car=,cdr,:cond
   \\{
      define_BNCONDEXPR
      define_BCONDEXPR
      define_BCONDEL
      define_BNCONDEL
      BNCONDEXPR label,cond
      purge BNCONDEXPR,BCONDEXPR,BCONDEL,BNCONDEL
      define COND
   \\}
   match c,cond ; replace gt and lt
   \\{
      match =COND =signed v1>==v2, COND c
      \\\{
          cmp v1,v2
          blt label
          define COND
      \\\}
      match =COND =signed v1<==v2, COND c
      \\\{
          cmp v1,v2
          bgt label
          define COND
      \\\}
      match =COND v1>==v2, COND c
      \\\{
          cmp v1,v2
          blo label
          define COND
      \\\}
      match =COND v1<==v2, COND c
      \\\{
          cmp v1,v2
          bhi label
          define COND
      \\\}
      match =COND v1==v2, COND c
      \\\{
          cmp v1,v2
          bne label
          define COND
      \\\}
      match =COND v1<>v2, COND c
      \\\{
          cmp v1,v2
          beq label
          define COND
      \\\}
      match =COND =signed v1>v2, COND c
      \\\{
          cmp v1,v2
          ble label
          define COND
      \\\}
      match =COND =signed v1<v2, COND c
      \\\{
          cmp v1,v2
          bge label
          define COND
      \\\}
      match =COND v1>v2, COND c
      \\\{
          cmp v1,v2
          bls label
          define COND
      \\\}
      match =COND v1<v2, COND c
      \\\{
          cmp v1,v2
          bhs label
          define COND
      \\\}
      match =COND =ZERO?, COND c
      \\\{
          bne label
          define COND
      \\\}
      match =COND =CARRY?, COND c
      \\\{
          bcc label
          define COND
      \\\}
      match =COND =OVERFLOW?, COND c
      \\\{
          bvc label
          define COND
      \\\}
      match =COND =SIGN?, COND c
      \\\{
          bpl label
          define COND
      \\\}
      match =COND v, COND c
      \\\{
          if v eqtype 0
           if ~ v
            b label
           end if
          else
           cmp v,0
           beq label
          end if
      \\\}
   \\}
 \}
}

macro define_BCONDEL
{
 macro BCONDEL label,cond
 \{
   \local COND
   match car=,cdr,:cond
   \\{
      define_BNCONDEXPR
      define_BCONDEXPR
      define_BCONDEL
      define_BNCONDEL
      BCONDEXPR label,cond
      purge BNCONDEXPR,BCONDEXPR,BCONDEL,BNCONDEL
      define COND
   \\}
   match c,cond ; replace gt and lt
   \\{
      match =COND =signed v1>==v2, COND c
      \\\{
          cmp v1,v2
          bge label
          define COND
      \\\}
      match =COND =signed v1<==v2, COND c
      \\\{
          cmp v1,v2
          ble label
          define COND
      \\\}
      match =COND v1>==v2, COND c
      \\\{
          cmp v1,v2
          bhs label
          define COND
      \\\}
      match =COND v1<==v2, COND c
      \\\{
          cmp v1,v2
          bls label
          define COND
      \\\}
      match =COND v1==v2, COND c
      \\\{
          cmp v1,v2
          beq label
          define COND
      \\\}
      match =COND v1<>v2, COND c
      \\\{
          cmp v1,v2
          bne label
          define COND
      \\\}
      match =COND =signed v1>v2, COND c
      \\\{
          cmp v1,v2
          bgt label
          define COND
      \\\}
      match =COND =signed v1<v2, COND c
      \\\{
          cmp v1,v2
          blt label
          define COND
      \\\}
      match =COND v1>v2, COND c
      \\\{
          cmp v1,v2
          bhi label
          define COND
      \\\}
      match =COND v1<v2, COND c
      \\\{
          cmp v1,v2
          blo label
          define COND
      \\\}
      match =COND =ZERO?, COND c
      \\\{
          beq label
          define COND
      \\\}
      match =COND =CARRY?, COND c
      \\\{
          bcs label
          define COND
      \\\}
      match =COND =OVERFLOW?, COND c
      \\\{
          bvs label
          define COND
      \\\}
      match =COND =SIGN?, COND c
      \\\{
          bmi label
          define COND
      \\\}
      match =COND v, COND c
      \\\{
          if v eqtype 0
           if v
            b label
           end if
          else
           cmp v,0
           bne label
          end if
      \\\}
   \\}
 \}
}

define_BNCONDEXPR
define_BCONDEXPR
define_BNCONDEL
define_BCONDEL
    
I could include it in the download as ARMIF.INC if it works.


Last edited by revolution on 16 Mar 2015, 23:28; edited 1 time in total
Post 16 Mar 2015, 13:13
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Amazing, thanks!

Few jmp instructions have remained and need to be changed, here's one,

Code:
    ; no pass
    .while r0
        sub r0, r0, 2
    .endw

c:\fasmarm\include\macro\armif.inc [57] .endw [1]:
  jmp __WHILE 
error: illegal instruction.
    


Afterwards, here are few tests that pass.

Code:
    ; pass
    .if r0 <= 100 & ( r1 | r2 )

    .endif

    ; pass
    .repeat
        add r0, r0, 2
    .until r0>100

    ; pass
    .while r0
        sub r0, r0, 2
    .endw

    ; pass
    .if r0

    .elseif r1

    .else

    .endif
    
Post 16 Mar 2015, 22:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
I edited the post above to replace the three "jmp" with "b".
Post 16 Mar 2015, 23:30
View user's profile Send private message Visit poster's website Reply with quote
nmyo



Joined: 26 Aug 2011
Posts: 4
Location: Las Vegas, NV
nmyo
Using apostrophes inside numbers is possible in FASM but not in FASMARM. I was wondering if the removal of this feature is intentional since it's not documented, at least in FASM.PDF.

For example, these lines assemble in FASM:
Code:
db 1'2'3
dw 00001111'11000000b
dd 100F'F001h    


But these do not in FASMARM:
Code:
db 1'2'3
dh 00001111'11000000b
dw 100F'F001h    


EDIT: Thanks for the reply ↓, I didn't know about underscore.


Last edited by nmyo on 27 Apr 2015, 02:44; edited 1 time in total
Post 25 Apr 2015, 20:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Use the underscore. This is the normal ARM code format.
Code:
db 1_2_3
dh 00001111_11000000b
dw 100F_F001h    
This was documented in the revision history.
Quote:
v1.15 2010-Apr-21 ...
- Changed numeric separation character from single quote (') to underscore (_)
Post 25 Apr 2015, 23:39
View user's profile Send private message Visit poster's website Reply with quote
den_po



Joined: 17 Jul 2006
Posts: 23
Location: Russia, Cheboksary
den_po
flat assembler for ARM version 1.71.31 (1048576 kilobytes memory)
test.asm [4]:
mrc p15, 0, r15, c7, c10, 3
error: PC (R15) not valid as third parameter.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0198e/I1014942.html
Quote:
The test and clean DCache instruction, MRC p15, 0, r15, c7, c10, 3, is a special encoding that uses r15 as a destination operand. However, the PC is not changed by using this instruction. This MRC instruction also sets the condition code flags.

_________________
JUST_DAn_PO
Post 27 May 2015, 14:51
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: 17671
Location: In your JS exploiting you and your system
revolution
den_po wrote:
flat assembler for ARM version 1.71.31 (1048576 kilobytes memory)
test.asm [4]:
mrc p15, 0, r15, c7, c10, 3
error: PC (R15) not valid as third parameter.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0198e/I1014942.html
Quote:
The test and clean DCache instruction, MRC p15, 0, r15, c7, c10, 3, is a special encoding that uses r15 as a destination operand. However, the PC is not changed by using this instruction. This MRC instruction also sets the condition code flags.
Thanks for the report. Actually this bug goes back even further than just the DCache instruction. It affects all MRC instructions. Here is the quote from original DDI0100 document.
Quote:
Specifies the destination ARM register for the instruction. If R15 is specified for <Rd>, the condition code flags are updated instead of a general-purpose register.
Post 28 May 2015, 01:55
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: 17671
Location: In your JS exploiting you and your system
revolution
Version 1.33 now available:
Quote:
v1.33 2015-May-28
  • Added on demand memory allocation for WIN32
  • Fixed MRC bug with R15 as the destination
This has been compiled against fasm v1.71.39 and thus adds the command line pre-defintions functionality and fixes a few minor bugs.

Note that this release also adds an additional file SYSTEMARM.INC to accommodate the on demand memory allocation in the WIN32 command line fasmarm.exe. This reduces memory usage for small files and allows for larger files to be assembled, but can be overridden by using the command line -m switch. This does not affect the IDE memory allocation.
Post 28 May 2015, 01:59
View user's profile Send private message Visit poster's website Reply with quote
den_po



Joined: 17 Jul 2006
Posts: 23
Location: Russia, Cheboksary
den_po
E:\>FASMARM.EXE change_AT_CLCC.asm
flat assembler for ARM version 1.71.39 (1572672 kilobytes memory)
error: out of memory.

Windows XP x86


Description:
Download
Filename: change_AT_CLCC.asm
Filesize: 807 Bytes
Downloaded: 209 Time(s)

Post 18 Jun 2015, 12:50
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: 17671
Location: In your JS exploiting you and your system
revolution
Version 1.34 now available:
Quote:
v1.34 2015-Jun-18
  • Fixed a bug with elf section offsets using "at"
This has been compiled against fasm v1.71.39.
Quote:
>fasmarm -m 11 change_AT_CLCC.asm
flat assembler for ARM version 1.71.39 (11 kilobytes memory)
5 passes, 1308 bytes.
Post 18 Jun 2015, 14:34
View user's profile Send private message Visit poster's website Reply with quote
den_po



Joined: 17 Jul 2006
Posts: 23
Location: Russia, Cheboksary
den_po
Thank you
Post 18 Jun 2015, 14:52
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: 17671
Location: In your JS exploiting you and your system
revolution
den_po wrote:
Windows XP x86
Still the best OS. So sad that it is being abandoned. Crying or Very sad
Post 18 Jun 2015, 14:53
View user's profile Send private message Visit poster's website Reply with quote
Andrew Martin



Joined: 30 Sep 2015
Posts: 29
Location: 404, Lugansk
Andrew Martin
Possibly invalid symbols table in ELF DWARF format Sad


Description: Source code:
Download
Filename: Source.zip
Filesize: 311.85 KB
Downloaded: 190 Time(s)

Description: Compilation & disassembly log:
Download
Filename: log.txt
Filesize: 16.53 KB
Downloaded: 239 Time(s)

Post 30 Sep 2015, 08:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Andrew Martin wrote:
Possibly invalid symbols table in ELF DWARF format Sad
Thank you for the report and the sources to show the error. A fix will come shortly.
Post 01 Oct 2015, 00:24
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: 17671
Location: In your JS exploiting you and your system
revolution
Version 1.35 now available:
Quote:
v1.35 2015-Oct-01
  • Fixed a bug with elf dwarf format file corruption
Post 01 Oct 2015, 00:29
View user's profile Send private message Visit poster's website Reply with quote
Andrew Martin



Joined: 30 Sep 2015
Posts: 29
Location: 404, Lugansk
Andrew Martin
Please look to the symbols names in the symbols table. There must be the names of labels, names of sections, etc. but not ASCII garbage.


Description:
Download
Filename: log.txt
Filesize: 4.81 KB
Downloaded: 155 Time(s)

Post 01 Oct 2015, 08:29
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 24, 25, 26 ... 30, 31, 32  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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.