flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] Undefined symbol 'read_hex'

Author
Thread Post new topic Reply to topic
Bodo



Joined: 18 Apr 2020
Posts: 6
Bodo 19 Apr 2020, 20:06
Hi Guys,

I am trying to write my first program and i keep getting the error, undefined symbol 'read_hex'. Can someone please tell me what's wrong with my commands:

Code:
; This is a prgram for adding numbers.

format PE console
entry start

include 'win32a.inc'

;-----------------------------------------------------------
section '.text' code readable executable

start:
        ; Your program begins here:
        
        ; Read two numbers from the user:
        call    read_hex
        mov             edx,eax
        call    read_hex
        
        ; add the two numbers:
        add             eax,edx
        
        ; Print result to the console:
        call    print_eax
        
        ; Exit the process:
        push    0
        call    [Exitprocess]    
Edit by revolution: Added code tags
Post 19 Apr 2020, 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: 20430
Location: In your JS exploiting you and your system
revolution 19 Apr 2020, 21:34
You need to provide the label read_hex and also print_hex
Code:
start:
  ;...

read_hex:
  ;fill in your code here

print_hex:
  ;fill in your code here

.end ; <--- allow the windows macros to close off the file    
Post 19 Apr 2020, 21:34
View user's profile Send private message Visit poster's website Reply with quote
Bodo



Joined: 18 Apr 2020
Posts: 6
Bodo 19 Apr 2020, 23:28
Now i am getting error, undefined symbol Exitprocess." Please help! My code is below:

; This is a prgram for adding numbers.

format Pe console
entry start

include 'win32a.inc'

;-----------------------------------------------------------
section '.text' code readable executable

start:

read_hex:
mov edx,eax

add eax,edx


print_hex:

section '.idata' import data readable

invoke ExitProcess,0
Post 19 Apr 2020, 23:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 20 Apr 2020, 00:25
You need the ".end" at the end to allow the macros to complete the import section.

See the "examples" folder in the fasm download, they show the ways you can do this.
Post 20 Apr 2020, 00:25
View user's profile Send private message Visit poster's website Reply with quote
Bodo



Joined: 18 Apr 2020
Posts: 6
Bodo 20 Apr 2020, 02:46
I got it now.

Thank you.
Post 20 Apr 2020, 02:46
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
Ali.Z 20 Apr 2020, 03:19
you need a basic understanding of your target OS, how executables work in that OS.

since you are using windows os, you need minimum of 1 section and you must construct the import table.

Code:
format pe gui                                           ; executable type and subsystem
include 'win32a.inc'                                    ; useful macros, that what makes an all in one section
; note that win32 for 32-bit programs and 'a' for ascii/ansi


                        ; using win32a.inc, we can omit the API variant (a,w) ..
        invoke          MessageBox,0,_construct,_flat,0 ; library function
        ret



_flat db '.flat section have code and data resides in it',0
_construct db 'although fasm create a .flat section for both code and data',0Dh,0Ah,'but you must construct the import table',0

data import                         ; begin of import table

        library user32,'user32.dll' ; MessageBoxA resides here
        include 'api\user32.inc'    ; the include file that have all library functions

end data                            ; end of import table    

_________________
Asm For Wise Humans
Post 20 Apr 2020, 03:19
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.