flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > [solved] Assembly old code

Author
Thread Post new topic Reply to topic
Dex



Joined: 03 Feb 2024
Posts: 3
Dex 03 Feb 2024, 13:54
Hi, i have some old code i written for fasmarm, iv not coded in about 12 year, when i try assembling it i get errors eg:
Quote:
./fasmarm test2.asm
flat assembler for ARM version 1.44 (built on fasm 1.73.30) (16384 kilobytes memory)
test2.asm [7]:
entry start ;
processed: entry start
error: undefined symbol 'start'.

When the code is :
Code:
;======================================================;
; Tiny Server.                                         ;
;------------------------------------------------------;
; By Craig Bamford (Dex)                  (11-03-2013) ;
;------------------------------------------------------;
format ELF executable                                  ;
entry start                                            ;
;======================================================;
; Is logging enabled ?                                 ;
;------------------------------------------------------;
LOGGING = 1                                            ;
LOGGING2 = 0                                           ;
;======================================================;
; Def                                                  ;
;------------------------------------------------------;
SOCK_STREAM       = 1                                  ;
AF_INET           = 2                                  ;
SYS_socketcall    = 102                                ;
SYS_SOCKET        = 1                                  ;
SYS_CONNECT       = 3                                  ;
SYS_SEND          = 9                                  ;
SYS_RECV          = 10                                 ;
IPPROTO_TCP       = 6                                  ;   Transmission Control Protocol
;======================================================;
; Print macro                                          ;
;------------------------------------------------------;
macro print _msg,_msglen                               ;
{ common                                               ;
        push      (r0)                                 ;
        push      (r1)                                 ;
        push      (r2)                                 ;
        push      (r7)                                 ;
        mov       r7, 0x4                              ;
        mov       r0, 0x1                              ;
        imm32     r1, _msg                             ;
        imm32     r2, _msglen                          ;
        swi       0x0                                  ;
                                                       ;
        pop       (r7)                                 ;
        pop       (r2)                                 ;
        pop       (r1)                                 ;
        pop       (r0)                                 ;
}                                                      ;
;======================================================;
; old tcpsend macro                                    ;
;------------------------------------------------------;
macro tcpsend _msg,_msglen                             ;
{ common                                               ;
        push      (r0)                                 ;
        push      (r1)                                 ;
        push      (r2)                                 ;
        push      (r3)                                 ;
        push      (r7)                                 ;
        imm32     r0, clientfd                         ;
        ldr       r0, [r0]                             ;
        imm32     r1, _msg                             ;
        imm32     r2, _msglen                          ;
        mov       r3, 0                                ;
        imm32     r7, 0x121                            ;
        swi       0x0                                  ;
        pop       (r7)                                 ;
        pop       (r3)                                 ;
        pop       (r2)                                 ;
        pop       (r1)                                 ;
        pop       (r0)                                 ;
}                                                      ;
;======================================================;
; old tcpsend macro                                    ;
;------------------------------------------------------;
; r0 = size to send                                    ;
;------------------------------------------------------;
macro tcpsend_reg _msg                                 ;
{ common                                               ;
        push      (r0)                                 ;
        push      (r1)                                 ;
        push      (r2)                                 ;
        push      (r3)                                 ;
        push      (r7)                                 ;
        mov       r2, r0                               ;
        imm32     r0, clientfd                         ;
        ldr       r0, [r0]                             ;
        imm32     r1, _msg                             ;
        mov       r3, 0                                ;
        imm32     r7, 0x121                            ;
        swi       0x0                                  ;
        pop       (r7)                                 ;
        pop       (r3)                                 ;
        pop       (r2)                                 ;
        pop       (r1)                                 ;
        pop       (r0)                                 ;
}                                                      ;
;======================================================;
; Print macro                                          ;
;------------------------------------------------------;
;  r0 = string size                                    ;
;------------------------------------------------------;
macro print_reg _msg,_msglen                           ;
{ common                                               ;
        push      (r0)                                 ;
        push      (r1)                                 ;
        push      (r2)                                 ;
        push      (r7)                                 ;
        mov       r2, r0                               ;
        mov       r7, 0x4                              ;
        mov       r0, 0x1                              ;
        imm32     r1, _msg                             ;
        swi       0x0                                  ;
                                                       ;
        pop       (r7)                                 ;
        pop       (r2)                                 ;
        pop       (r1)                                 ;
        pop       (r0)                                 ;
}                                                      ;
include 'FasmArm.inc'                              ;
segment readable writeable executable                  ;
;======================================================;
; Main start                                           ;
;------------------------------------------------------;
start:                                                 ;
        print msg,msg.msg_size                         ; print start message
;======================================================;
; Check commamd line for port number                   ;
;------------------------------------------------------;
        ldmfd     sp!, {r1}                            ;
        imm32     r0, argc                             ;
        str       r1, [r0]                             ;
        mov       r0, 80                               ; default port number
        cmp       r1, 1                                ;
    

Now when i assembly it with a old ver of fasmarm, it assembles fine.
OLD ver is 0.95.10
All the errors seem to be offset address.
Thanks for any help.
Post 03 Feb 2024, 13:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 03 Feb 2024, 14:01
A file is missing.
Code:
include 'FasmArm.inc'                              ;
error: file not found.    
If I replace with this code:
Code:
;include 'FasmArm.inc'
macro imm32 arg& {nop}    
Output is this:
Code:
2 passes, 156 bytes.    
BTW: fasmarm versions numbers are d.dd, so 0.95.10 is probably the GUI version for fasmwarm.
Post 03 Feb 2024, 14:01
View user's profile Send private message Visit poster's website Reply with quote
Dex



Joined: 03 Feb 2024
Posts: 3
Dex 03 Feb 2024, 14:57
Ok, thanks revolution
Post 03 Feb 2024, 14:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 03 Feb 2024, 15:07
Can we assume you found and fixed a bug in "FasmArm.inc"?
Post 03 Feb 2024, 15:07
View user's profile Send private message Visit poster's website Reply with quote
Dex



Joined: 03 Feb 2024
Posts: 3
Dex 03 Feb 2024, 15:37
Yes, it was i have two ver it seems, of the macro file eg; one upper case and one ver lower case and other differences , so all fixed now thanks.
Post 03 Feb 2024, 15:37
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.