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 ... 14, 15, 16 ... 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: 17270
Location: In your JS exploiting you and your system
revolution
rxantos wrote:
The iPhone processor is an ARM1176JZF

Can this assemble instructions for this processor?
Yes, that uses the ARMv6 instruction set.
rxantos wrote:
And if so, can it output the object format for the iPhone?
fasmarm outputs ELF, ELF DWARF and PE formats natively. If the iPhone doesn't support any of those then there is always binary format.
Post 20 Aug 2009, 01:43
View user's profile Send private message Visit poster's website Reply with quote
nathanpc



Joined: 23 Aug 2009
Posts: 40
Location: Brazil
nathanpc
That's cool! Shocked
I'm going to learn more about it! Very Happy

_________________
Developer: C++, Java, C/C++, Java ME, Java EE, Pascal, Assembly(8086, 6502, z80, ARM and MIPS), Delphi, Visual Basic, Pascal, Ruby and Perl
Post 15 Sep 2009, 17:43
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
I learned a little about freeBSD last summer before the beat me up for asking un-common/maybe stupit questions. Today I signed up for Linux for next semester and learn I may be force to use Redhat. So to make sure that I will be happy (more low-level/less automation), I concluded netBSD, Arch Linux and Gentoo as my side kick studies to relate them to Fasm coding because of this thread.

http://board.flatassembler.net/topic.php?t=2947

I remember reading a little bit into FasmArms. Just now, I only read the first few threads seriously for the first time and went straight to the bottom (page 15) and found out FasmArms can code for the iPhone. So I did some searching and just ran into this:

http://en.wikipedia.org/wiki/BlackBerry

"Modern GSM-based BlackBerry handhelds incorporate an ARM 7 or 9 processor, while older BlackBerry 950 and 957 handhelds used Intel 80386 processors."

Am I'm dreaming again ... do this mean we can use FasmArms to write applications for the BlackBerry toooooo? If so, WOW!

Do this mean I don't have to take a Java class next semester because we got FasmArm to get the job done for both major handheld devices on the planet? If so, UN-BELIEVABLE.
Post 19 Dec 2009, 07:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
Yes, ARM7 and ARM9 are supported by fasmarm.
Post 19 Dec 2009, 07:05
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Every device that as had a ARM chip and i have tryed to code for using FasmARM its worked fine, but this has been on the bare metal, as i work on porting my OS, but you will find alot of these devicers will not let you, run your code on top of the devicers OS, so check if its web based only, unless you want to boot your code.

DexOS booting on a arm, using FasmArm
Image
Post 19 Dec 2009, 20:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
I have updated the package to v1.14
Code:
v1.14 2010-Feb-02 - Updated for compatibility with FASM 1.69.11
                  - Changed "LDRx reg,[reg,0]!" to generate  "LDRx reg,[reg,0]"
                  - Changed "LDRx reg,[reg],0" to generate  "LDRx reg,[reg,0]"
                  - Changed "LDC Px,Cx,[reg,0]!" to generate  "LDC Px,Cx,[reg,0]"
                  - Changed "LDC Px,Cx,[reg],0" to generate  "LDC Px,Cx,[reg,0]"
                  - Fixed encoding for thumb mode BLX
                  - Fixed encoding for PKHTB without shift
                  - Fixed encoding for SSAT, SSAT16
                  - Fixed encoding for UMAAL
                  - Allowed rotation parameter for SXTB, SXTH, UXTB, UXTH    
Soon to come (in a few months) support for the latest v7 instructions and T2 with UAL mode assembly.
Post 10 Feb 2010, 18:57
View user's profile Send private message Visit poster's website Reply with quote
v_over



Joined: 09 Mar 2009
Posts: 4
Location: Russia
v_over
How in the ARMFASM to specify the address data from the other sections?
*Error: add r1,pc,Text-$-8 cannot be encoded*
Code:
        format  PE GUI
        entry   Start

section '.data' data readable writeable

        Text    du      'Hello WinCE world',0
        Caption du      'ARM small PE',0

section '.text' data code readable executable

Start:
        mov     r0,0                    
        add     r1,pc,Text-$-8         
        add     r2,pc,Caption-$-8       
        mov     r3,0                   
        ldr     pc,[pc,MessageBoxW-$-8]        

And what more fast?
Code:
mov     r0,0   
;OR
eor   r0, r0, r0  ; As on x86 
    
Post 21 Feb 2010, 13:03
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
v_over wrote:
How in the ARMFASM to specify the address data from the other sections?
*Error: add r1,pc,Text-$-8 cannot be encoded*
Use the adrl macro:
Code:
   format  PE GUI
      entry   Start

macro adrl reg,address {
  add reg,pc,(address-$-8) and 0xff
   add reg,reg,(address-$-4) and 0xffffff00
}

section '.data' data readable writeable

     Text    du      'Hello WinCE world',0
     Caption du      'ARM small PE',0

section '.text' data code readable executable

Start:
 mov     r0,0
        adrl    r1,Text
     adrl    r2,Caption
  mov     r3,0
        ldr     pc,[pc,MessageBoxW-$-8]    
v_over wrote:

And what more fast?
Code:
mov     r0,0   
;OR
eor       r0, r0, r0  ; As on x86 
    
'mov' is faster in some circumstances. If there is a pending operation to produce a result to r0 (like a multiply) then you will get a resource stall due to r0 being unknown.

But if there is no pending previous operation affecting r0 then it makes no difference which you use.


Last edited by revolution on 22 Feb 2010, 12:59; edited 1 time in total
Post 21 Feb 2010, 14:39
View user's profile Send private message Visit poster's website Reply with quote
v_over



Joined: 09 Mar 2009
Posts: 4
Location: Russia
v_over
revolution, thx.
Now I tried to create a window, but for some reason I have after the procedure call(CreateWindowExW), the program flies where the devils, and turn't back (. Maybe I did't work properly with the stack? On the emulator (WM 6.5) displays a window (not redrawn) and hangs.
Code:
include 'wince.inc'

macro  adr reg,location {
       add  reg,pc,location-$-8
}
macro adrl reg,address {
        add reg,pc,(address-$-8) and 0xff 
        add reg,reg,(address-$-8) and 0xffffff00 
}

struct  WNDCLASS
        style           dw 0x3
        lpfnWndProc     dw WindowProc
        cbClsExtra      dw 0
        cbWndExtra      dw 0
        hInstance       dw 0
        hIcon           dw 0
        hCursor         dw 0
        hbrBackground   dw 0
        lpszMenuName    dw 0
        lpszClassName   dw mestit
ends

WM_NULL         equ     0x0000
WM_CREATE       equ     0x0001
WM_DESTROY      equ     0x0002

WM_CLOSE        equ     0x0010
WM_QUIT         equ     0x0012
;===================================================
        format  PE GUI
        entry   start

section '.data' data readable
        Caption du      'ARM example',0
        Text    du      'Hello ArmCE world',0
        mestit  du      'Asm'

section '.bss' data readable writeable
        wc  WNDCLASS <>
        hInstance dw ?
        HWND      dw ?

section '.code' code readable executable

WindowProc:
        stmfd   sp!, {r4-r6,lr}
        cmp     r1, WM_DESTROY
        beq     wmdestroy
        b       def
wmdestroy:
        mov     r0,0
        bl      PostQuitMessage
        b       ret
def:
        bl      DefWindowProcW
ret:
        ldmfd   sp!, {r4-r6,pc}

start:
        apscall GetModuleHandleW,0
        adrl    R1,hInstance
        STR     R0,[R1]

        adrl    R1, wc
        STR     R0,[R1,WNDCLASS.hInstance]
        mov     R0, r1
        BL      RegisterClassW          ;ALL OK
        apscall GetLastError            ;No error

        SUB     SP, SP, 0x20            ;Singling stack

        MOV     LR, 0x80000000
        STR     LR, [SP]                ;x
        STR     LR, [SP,0x4]            ;y
        STR     LR, [SP,0x8]            ;nWidth
        STR     LR, [SP,0xC]            ;nHeight

        MOV     LR, 0
        STR     LR, [SP,0x10]           ;hWndParen
        STR     LR, [SP,0x14]           ;hMenu

        adrl    R1, hInstance
        ldr     LR,[r1]
        STR     LR, [SP,0x18]           ;hInstance

        MOV     LR, 0
        STR     LR, [SP,0x1C]           ;lpParam

        MOV     R3, 0x10000000          ;dwStyle

        adrl    R2, Caption             ;lpWindowName
        adrl    R1, mestit              ;lpClassName,

        MOV     R0, 0                   ;dwExStyle

        bl      CreateWindowExW          ; <== ERROR
        adrl    R1,HWND
        STR     R0,[R1]

        ADD     SP, SP, 0x20

        cmp R0, 0
        BNE _end_if
                 mov     r0,0           ;window owner (NULL)
                 adrl     r1,Caption    ;the text
                 adrl     r2,Caption    ;the caption
                 mov     r3,0           ;style (MB_OK)
                 bl     MessageBoxW     ;display message
        _end_if:

        adrl   R1, HWND
        ldr     R0,[r1]
        bl ShowWindow

        apscall GetLastError
        mov r4,r0
      ;  apscall MessageBoxW,0,addr Text,addr Caption,0

section '.idata' import data readable writeable

        library coredll,'COREDLL.DLL'
        include 'APICE\COREDLL.INC'    
Post 22 Feb 2010, 12:19
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
v_over: You don't have any exit point. After the call to GetLastError the program goes to nowheresville. Are you sure the code is hanging at the point you show? I don't have an emulator to check.

BTW: The macro I posted above had an error. I have corrected it above and show it below also. It doesn't affect your code above but you may want to correct your source anyway.
Code:
macro adrl reg,address {
   add     reg,pc,(address-$-8) and 0xff
       add     reg,reg,(address-$-4) and 0xffffff00
}    
Post 22 Feb 2010, 13:15
View user's profile Send private message Visit poster's website Reply with quote
v_over



Joined: 09 Mar 2009
Posts: 4
Location: Russia
v_over
revolution: Yes, GetLastError is normally.(and without it, does't work Laughing)


Last edited by v_over on 22 Feb 2010, 14:36; edited 1 time in total
Post 22 Feb 2010, 14:21
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
v_over wrote:
revolution: Yes, GetLastError is normally.(and without it does't work Laughing)
I don't understand. Without what it doesn't work?

You should put in some way for your code to exit back to the OS cleanly. Since you never saved the starting LR value then you should make a call to ExitProcess to exit properly.
Post 22 Feb 2010, 14:32
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
revolution, please note that I know near to nothing about ARM programming, but why adrl can't be done this way?
Code:
macro adrl reg,address {
        add     reg,pc,0
        add     reg,reg,(address-$-4)
}    


Or there is some advantage with your way?
Post 22 Feb 2010, 14:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
LocoDelAssembly: The address is too far. Your first instruction is the same as 'mov reg,pc' and achieves nothing useful.

You can't simply encode just any constant in ARM code. Only values of up to 8 bits rotated by an even amount 0-30.

You can encode the following:

0xF000000F ;8 bits, 0xff rotated by 4
0xFF000000 ;8 bits, 0xff rotated by 8
0x000000FF ;8 bits, 0xff rotated by 0
0x0003FC00 ;8 bits, 0xff rotated by 22
0x00000204 ;8 bits 0x81 rotated by 30

You can't encode these:

0x00012345 ;more than 8 bits
0xF800000F ;9 bits, 0x3fe rotated by 6
0x00000101 ;9 bits
0x00000102 ;8 bits but no even rotation available, 0x81 rotate by 31?


Last edited by revolution on 22 Feb 2010, 15:57; edited 1 time in total
Post 22 Feb 2010, 15:07
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Oh, I see that it is much more complex than MIPS for instance (in which of course you need two instructions but each one participates in adding an even amount of bits in a more natural way).

I found the manual you told us to take the opportunity to download while it was available. By looking at it I found that it is not possible to load any 32-bit value with your macro, is this right? Is it possible to load at least all addresses below 2 GB?
Post 22 Feb 2010, 15:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
No, that simple macro only covers 64kB. Generally programs often fit within this size.

If you align everything to 4 then you can go to 256kB with two instructions.
Code:
macro adrl reg,address {
        add     reg,pc,(address-$-8) and 0x3ff ;unaligned stuff will error here
        add     reg,reg,(address-$-4) and 0xfffffc00 ;stuff too far will error here
}    
Post 22 Feb 2010, 15:27
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: 17270
Location: In your JS exploiting you and your system
revolution
You can extend it to cover all 4GB, but it needs 4 instructions.
Code:
macro adrl reg,address {
        add     reg,pc,(address-$-8) and 0xff
        add     reg,reg,(address-$-4) and 0xff00
        add     reg,reg,(address-$) and 0xff0000
        add     reg,reg,(address-$+4) and 0xff000000
}    
Post 22 Feb 2010, 15:30
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: 17270
Location: In your JS exploiting you and your system
revolution
LocoDelAssembly wrote:
I found the manual you told us to take the opportunity to download while it was available.
I am pleased you did because not long after I posted the link it became protected by a login wall.

But there is still some freely available (old) docs available here:

http://infocenter.arm.com/help/advanced/indexList.jsp
Post 22 Feb 2010, 15:39
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I have DDI0100I so I'm pretty outdated now Sad

In your last macro perhaps could be better (or at least easier) to use MOV first and 3 ADDs later (not involving $ anymore)?

Thanks for all the explanation and macros.
Post 23 Feb 2010, 00:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
LocoDelAssembly: Using 'mov' won't achieve anything useful. Would it make more sense like this?
Code:
macro adrl reg,address {
local offset
offset = address-$-8
        add     reg,pc,offset and 0xff
        add     reg,reg,offset and 0xff00
        add     reg,reg,offset and 0xff0000
        add     reg,reg,offset and 0xff000000
}    
Post 23 Feb 2010, 00:12
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 14, 15, 16 ... 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.

Powered by rwasa.