CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old December 1st, 2004, 03:05 PM
    YourSurrogateGod YourSurrogateGod is offline
    Senior Member
     
    Join Date: Apr 2004
    Location: In the back seat of New Horizons.
    Posts: 1,229
    YourSurrogateGod is a jewel in the rough (200+)YourSurrogateGod is a jewel in the rough (200+)YourSurrogateGod is a jewel in the rough (200+)
    Unable to compile assembly...

    I'm using nasm in order to mess around a little bit. Here is the small program that I would like to make. I got the source code from the below link (it's a book that's a pdf, but stored in a zipped file, the code start on page 29)...

    http://www.drpaulcarter.com/pcasm/re...m-book-pdf.zip

    Code:
    ; first assembly program.
    ; first_asm.asm
    
    ; to create an executable.
    ; nasm -f elf first.asm
    ; gcc -o first first.o driver.c asm_io.o
    
    %include "asm_io.inc"
    
    ; these labels refer to strings that are used for output.
    prompt1 db "Enter a number - > ", 0
    prompt2 db "Enter another number - > ", 0
    outmsg1 db "You entered ", 0
    outmsg2 db " and ", 0
    outmsg3 db ", the sum of these is ", 0
    
    ; uninitialized data is put into the .bss segment.
    segment .bss
    
    ; these labels refer to double words used to store the inputs.
    input1 resd 1
    input2 resd 1
    
    ; code is put into the .text segment.
    segment .text
       global asm_main
    asm_main
       enter 0, 0                 ; setup the routine.
       pusha
    
       mov eax, prompt1           ; move the prompt1 into the register.
       call print_string          ; print out the prompt1 to the screen.
    
       call read_int              ; call the read int and read that integer into the eax register.
       mov [input1], eax          ; store the data in the register in the input1 value. In this instance the brackets are
                   ;   used so as to write into the data part of the variable, as opposed the address one.
       call print_nl              ; give a new line.
    
       mov eax, prompt2           ; move the prompt2 into the register.
       call print_string          ; print out the prompt2 to the screen.
    
       call read_int              ; read another integer to the eax register.
       mov [input2], eax          ; store the value inside of eax into the label input2.
        call print_nl              ; give a new line.
    
       mov eax, [input1]          ; move the data in input1 to the eax register.
       add eax, [input2]          ; add the data inside of input2 to the one in register eax.
       mov ebx, eax               ; move the data in eax to ebx, so as to get it out of the way.
    
       dump_regs 1                ; print out the values in all of the registers.
       dump_mem 2, outmsg1, 1     ; print out the contents of the particular memory.
    
       ; print out the results message as a series of steps.
    
       mov eax, outmsg1           ; move the first message to the eax register. Note: Here you are passing the pointer
                                  ;   to the message, not the message itself inside of outmsg1.
       call print_string          ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is a string that is stored in label outmsg1.
    
       mov eax, [input1]          ; move the data of input1 to the register eax.
       call print_int             ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is an integer that is stored in label input1.
    
       mov eax, outmsg2           ; move the second message to the eax register.
       call print_string          ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is a string that is stored in label outmsg2.
    
       mov eax, [input2]          ; move the data of input2 to the register eax.
       call print_int             ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is an integer that is stored in label input2.
    
       mov eax, outmsg3           ; move the third and last message to the eax register.
       call print_string          ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is a string that is stored in label outmsg3.
    
       mov eax, ebx               ; move the previously stored value inside of ebx to eax.
       call print_int             ; print out the contents that are inside of register eax to the screen. In this
                                  ;   instance it is an integer that was stored in register ebx.
    
       call print_nl
    
       popa
       mov eax, 0                 ; return back to C.
       leave
       ret
    In order to assemble it, I inputted this command "nasm -f elf first.asm" and I got the below error...
    Code:
    first.asm:8: fatal: unable to open include file `asm_io.inc'
    I have NASM version 0.98.35 compiled on Sep 23 2003 and suse 9.0 kernel 2.4.

    My question is, what am I doing wrong?
    __________________
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.
    Reply With Quote
      #2    
    Old December 1st, 2004, 05:11 PM
    YourSurrogateGod YourSurrogateGod is offline
    Senior Member
     
    Join Date: Apr 2004
    Location: In the back seat of New Horizons.
    Posts: 1,229
    YourSurrogateGod is a jewel in the rough (200+)YourSurrogateGod is a jewel in the rough (200+)YourSurrogateGod is a jewel in the rough (200+)
    Re: Unable to compile assembly...

    Never mind figured it out.
    __________________
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.
    Reply With Quote
      #3    
    Old August 13th, 2007, 09:41 AM
    seimaya seimaya is offline
    Junior Member
     
    Join Date: Aug 2007
    Posts: 1
    seimaya is an unknown quantity at this point (<10)
    Re: Unable to compile assembly...

    hello, I know it's an old post, but how did you figure it out?
    Thanks for your help
    unable to open include file `asm_io.inc'
    Reply With Quote
      #4    
    Old September 24th, 2007, 03:16 PM
    AAR0N AAR0N is offline
    Junior Member
     
    Join Date: Sep 2007
    Posts: 1
    AAR0N is an unknown quantity at this point (<10)
    Re: Unable to compile assembly...

    Hello seimaya,

    Just in case you are still looking into this or somebody else comes across this in the future, the book web book has files to download along with the book to be used with the exercises. One of these files is the asm_io.inc file you are missing, place this file in the folder along with your first.asm file and run the command again.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:37 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009