flat assembler
Message board for the users of flat assembler.
Index
> Non-x86 architectures > FASMARM v1.44 - Cross assembler for ARM CPUs Goto page Previous 1, 2, 3, 4, 5 ... 31, 32, 33 Next |
Author |
|
revolution 14 Feb 2006, 02:15
Quote: 28h (40 DECIMAL!) I will attempt to make a quick patch for the existing version (1.04) but still intended to work with FASM v1.64. That should save you having to use a hex editor all the time. What value do you need for the flags to for it work correctly? Quote: Please let me know if I can be of any help with incorporating these things into the next version. BTW: Just to remind you that the ARM "word" is 32 bits, so your example above has this ... Code: test_data dd 0 You may find these macros helpful also. They are intended for PC relative addressing in ARM mode.: Code: macro adr reg,location { add reg,pc,location-$-8 } macro adrl reg,location { sub reg,pc,(-location+$+8) and (0ffh shl 2) sub reg,reg,(-location+$+4) and (0ffffff00h shl 2) } Last edited by revolution on 22 Feb 2010, 12:59; edited 1 time in total |
|||
14 Feb 2006, 02:15 |
|
Giant 14 Feb 2006, 02:36
Revolution, here is the source for arm-linux-as. I hacked it from the c-compiled code (god, my eyes still reel from the sheer ugliness! No wonder all current appls are megabytes of code - gcc is atrocious!). I know there is a better way to load a pc-relative address of the string... I am still stumbling around with the ARM architecture
Code: .file "hello.c" .text .align 2 .global _start _start: mov r0,#0 @ out ldr r1, .L7 mov r2,#12 swi 0x900004 mov r0,#6 swi 0x900001 .align 2 .L7: .word .LC0 .size _start,.-_start .section .rodata .align 2 .LC0: .ascii "Hello World\n\000" .ident "Giant" After assembly and linkage with no startup code it becomes: Code: 0000000: 7f45 4c46 0101 0161 0000 0000 0000 0000 .ELF...a........ 0000010: 0200 2800 0100 0000 7480 0000 3400 0000 ..(.....t...4... 0000020: d400 0000 0202 0000 3400 2000 0200 2800 ........4. ...(. 0000030: 0700 0600 0100 0000 0000 0000 0080 0000 ................ 0000040: 0080 0000 a000 0000 a000 0000 0500 0000 ................ 0000050: 0080 0000 0100 0000 a000 0000 a000 0100 ................ 0000060: a000 0100 0000 0000 0000 0000 0600 0000 ................ 0000070: 0080 0000 0000 a0e3 0c10 9fe5 0c20 a0e3 ............. .. 0000080: 0400 90ef 0600 a0e3 0100 90ef 9080 0000 ................ 0000090: 4865 6c6c 6f20 576f 726c 640a 0000 0000 Hello World..... 00000a0: 0047 6961 6e74 0000 2e73 6873 7472 7461 .Giant...shstrta 00000b0: 6200 2e74 6578 7400 2e72 6f64 6174 6100 b..text..rodata. 00000c0: 2e64 6174 6100 2e62 7373 002e 636f 6d6d .data..bss..comm 00000d0: 656e 7400 0000 0000 0000 0000 0000 0000 ent............. 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000f0: 0000 0000 0000 0000 0000 0000 0b00 0000 ................ 0000100: 0100 0000 0600 0000 7480 0000 7400 0000 ........t...t... 0000110: 1c00 0000 0000 0000 0000 0000 0400 0000 ................ 0000120: 0000 0000 1100 0000 0100 0000 0200 0000 ................ 0000130: 9080 0000 9000 0000 1000 0000 0000 0000 ................ 0000140: 0000 0000 0400 0000 0000 0000 1900 0000 ................ 0000150: 0100 0000 0300 0000 a000 0100 a000 0000 ................ 0000160: 0000 0000 0000 0000 0000 0000 0100 0000 ................ 0000170: 0000 0000 1f00 0000 0800 0000 0300 0000 ................ 0000180: a000 0100 a000 0000 0000 0000 0000 0000 ................ 0000190: 0000 0000 0100 0000 0000 0000 2400 0000 ............$... 00001a0: 0100 0000 0000 0000 0000 0000 a000 0000 ................ 00001b0: 0700 0000 0000 0000 0000 0000 0100 0000 ................ 00001c0: 0000 0000 0100 0000 0300 0000 0000 0000 ................ 00001d0: 0000 0000 a700 0000 2d00 0000 0000 0000 ........-....... 00001e0: 0000 0000 0100 0000 0000 0000 ............ I will post a fasm version of hello world tomorrow. |
|||
14 Feb 2006, 02:36 |
|
revolution 14 Feb 2006, 05:30
Given the dump above it seems gnu does not follow the ELF specifications. Although that is not suprising really because ARM also don't even follow there own specifications.
Based on the above I have updated the code in the first page of this thread to version 1.05 to give basic support for elf executable format and included a hello world example in elf format. But it is untested, feel free to test it if you get a chance. |
|||
14 Feb 2006, 05:30 |
|
Giant 14 Feb 2006, 14:25
I haven't had a chance to assemble the example provided in 1.05, but I remember not being able to assemble the SWI instructions without code32...
|
|||
14 Feb 2006, 14:25 |
|
revolution 14 Feb 2006, 15:31
Quote: armelf.asm needs code32 |
|||
14 Feb 2006, 15:31 |
|
Artlav 14 Feb 2006, 16:41
Well done, revolution!
armelf assembles and runs fine without any hexeditor mods. Tested at Cacko linux 1.23 on Xscale-PXA270 (armv4l). Btw, anyone tryed running fasmarm on the arm host with qemu? It runs fine, but takes about half-a-minute to assemble armelf. And, somewhy, it says 2419000.0 seconds of run-time instead of 24.19. No other bugs noticed. |
|||
14 Feb 2006, 16:41 |
|
Giant 14 Feb 2006, 21:01
400MHz Intel XScale PXA255 (arm5te) on gumstix linux kernel 2.6.15gum works. Thank you
|
|||
14 Feb 2006, 21:01 |
|
vid 15 Feb 2006, 14:40
revolution move FASM-ARM version to projects section please...
|
|||
15 Feb 2006, 14:40 |
|
revolution 15 Feb 2006, 17:01
Quote: revolution move FASM-ARM version to projects section please... |
|||
15 Feb 2006, 17:01 |
|
decard 15 Feb 2006, 17:28
No, you need to be a moderator to do that.
I've just moved it |
|||
15 Feb 2006, 17:28 |
|
vid 15 Feb 2006, 17:42
i meant new thread... with relevant first post and moderated rest... but this is also okay. It would be best if everyone could moderate his own project thread to keep it clear, but i am not sure if it is possible with phpBB
|
|||
15 Feb 2006, 17:42 |
|
vid 23 Feb 2006, 19:05
doesn't arm have any instructions working with 8bit arguments?
|
|||
23 Feb 2006, 19:05 |
|
revolution 24 Feb 2006, 01:01
Quote: doesn't arm have any instructions working with 8bit arguments? |
|||
24 Feb 2006, 01:01 |
|
vid 24 Feb 2006, 04:39
so if you changed meaning of "word" to 32 bits, then what is size operator for 8 and 16?
|
|||
24 Feb 2006, 04:39 |
|
revolution 24 Feb 2006, 05:19
8 bit is BYTE, 16 bit is HALF WORD, 32 bit is WORD, 64 bit is DOUBLE WORD. Respectively, DB, DH, DW, DD and RB, RH, RW, RD. This from the readme.txt in the download:
Code: X86 ARM comment ---+----+--------- DB | DB | same: 8 bits DW | DH | half word: 16 bits DU | DU | same: 16 bits DD | DW | word: 32 bits DQ | DD | double word: 64 bits RB | RB | same: 8 bits RW | RH | half word: 16 bits RD | RW | word: 32 bits RQ | RD | double word: 64 bits DF | -- | not valid DP | -- | not valid DT | -- | not valid RF | -- | not valid RP | -- | not valid RT | -- | not valid |
|||
24 Feb 2006, 05:19 |
|
revolution 24 Feb 2006, 05:39
Quote: then what is size operator for 8 and 16? Code: code32 virtual at 0 var_d dd 8 var_w dw 4 var_h dh 2,2 var_b db 1,1,1,1 end virtual ldrb r1,byte[r2,var_d] ldrb r1,byte[r2,var_w] ldrb r1,byte[r2,var_h] ldrb r1, [r2,var_b] ldrbt r1,byte[r2],var_d ldrbt r1,byte[r2],var_w ldrbt r1,byte[r2],var_h ldrbt r1, [r2],var_b ;armv4 ldrsb r1,byte[r2,var_d] ldrsb r1,byte[r2,var_w] ldrsb r1,byte[r2,var_h] ldrsb r1, [r2,var_b] ldrh r1,hword[r2,var_d] ldrh r1,hword[r2,var_w] ldrh r1, [r2,var_h] ldrh r1,hword[r2,var_b] ldrsh r1,hword[r2,var_d] ldrsh r1,hword[r2,var_w] ldrsh r1, [r2,var_h] ldrsh r1,hword[r2,var_b] ;armv1 ldr r1,word[r2,var_d] ldr r1, [r2,var_w] ldr r1,word[r2,var_h] ldr r1,word[r2,var_b] ldrt r1,word[r2],var_d ldrt r1, [r2],var_w ldrt r1,word[r2],var_h ldrt r1,word[r2],var_b ;armv5te ldrd r2, [r4,var_d] ldrd r2,dword[r4,var_w] ldrd r2,dword[r4,var_h] ldrd r2,dword[r4,var_b] ;armv1 strb r1,byte[r2,var_d] strb r1,byte[r2,var_w] strb r1,byte[r2,var_h] strb r1, [r2,var_b] strbt r1,byte[r2],var_d strbt r1,byte[r2],var_w strbt r1,byte[r2],var_h strbt r1, [r2],var_b ;armv4 strh r1,hword[r2,var_d] strh r1,hword[r2,var_w] strh r1, [r2,var_h] strh r1,hword[r2,var_b] ;armv1 str r1,word[r2,var_d] str r1, [r2,var_w] str r1,word[r2,var_h] str r1,word[r2,var_b] strt r1,word[r2],var_d strt r1, [r2],var_w strt r1,word[r2],var_h strt r1,word[r2],var_b ;armv5te strd r2, [r4,var_d] strd r2,dword[r4,var_w] strd r2,dword[r4,var_h] strd r2,dword[r4,var_b] code16 ldr r1,word[r2,var_d] ldr r1, [r2,var_w] ldr r1,word[r2,var_h] ldr r1,word[r2,var_b] ldrb r1,byte[r2,var_d] ldrb r1,byte[r2,var_w] ldrb r1,byte[r2,var_h] ldrb r1, [r2,var_b] ldrh r1,hword[r2,var_d] ldrh r1,hword[r2,var_w] ldrh r1, [r2,var_h] ldrh r1,hword[r2,var_b] str r1,word[r2,var_d] str r1, [r2,var_w] str r1,word[r2,var_h] str r1,word[r2,var_b] strb r1,byte[r2,var_d] strb r1,byte[r2,var_w] strb r1,byte[r2,var_h] strb r1, [r2,var_b] strh r1,hword[r2,var_d] strh r1,hword[r2,var_w] strh r1, [r2,var_h] strh r1,hword[r2,var_b] |
|||
24 Feb 2006, 05:39 |
|
vid 24 Feb 2006, 05:46
revolution: well, i don't have any device to run it
|
|||
24 Feb 2006, 05:46 |
|
Giant 27 Feb 2006, 18:47
Here is a problem:
Code: myreg equ r1 ldmia myreg!,{r0,lr} ldmia does not work; somehow the ! is not parsed correctly unless the register preceding it is a real (not equated) ARM register... |
|||
27 Feb 2006, 18:47 |
|
UCM 27 Feb 2006, 23:11
maybe you would want to use fix instead of equ for a temporary replacement.
|
|||
27 Feb 2006, 23:11 |
|
Goto page Previous 1, 2, 3, 4, 5 ... 31, 32, 33 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.