10 Replies - 4507 Views - Last Post: 03 February 2013 - 10:08 AM

#1 andre1011  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 12-January 11

Simple input and output

Posted 01 February 2013 - 01:44 PM

Hello all, I am having a problem getting an assembler program to assemble. It takes in two numbers adds them
together and displays the result. My operating system is Windows 7 Professional. The IDE is Visual Studio 2008
with the Microsoft Macro Assembler and the linker subsystem set to Console (/SUBSYSTEM:CONSOLE) (MASM 32)

here is my code
;Example assembly language program that adds two numbers
.586
.MODEL FLAT
INCLUDE io.h                     ;header file for input/output
.STACK 4096

.DATA
  number1    DWORD   ?
  number2    DWORD   ?
  prompt1    BYTE    "Enter the first number ",0
  prompt2    BYTE    "Enter the second number ",0
  string     BYTE    40 DUP (?)
  resultLbl1 BYTE    "The sum is ",0
  sum        BYTE    11 DUP (?) 
   
.CODE
   _MainProc  PROC 
        input  prompt1,     string, 40          ;read ASCII characters
        atod   string                           ;convert string to integer
        mov    number1,     eax                 ;store in memory
        
        input  prompt2,     string, 40          ;repeat for second number
        atod   string 
        mov    number2,     eax 
        
        mov    eax,         number1             ;first number to EAX
        add    eax,         number2             ;add second number
        dtoa   sum,         eax                 ;convert to ASCII characters
        output resultLbl1,  sum                 ;output label and sum
        
        mov    eax,         0                   ;exit with return code 0
        ret
   _MainProc END
END                                             ;end of source code




here is the error I am getting

------ Build started: Project: orange, Configuration: Debug Win32 ------
Assembling...
Assembling: .\bobby.asm
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(1) : error A2008:syntax error : /
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(2) : error A2008:syntax error : io
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(3) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(4) : error A2008:syntax error : Copyright
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(5) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(6) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(7) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(8) : error A2008:syntax error : file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(9) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(10) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(11) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(12) : error A2008:syntax error : *
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(14) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(15) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(16) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(17) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(18) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(19) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(20) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(21) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(22) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(23) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(24) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(25) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(26) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(27) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(28) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(29) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(30) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(31) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(32) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(33) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(34) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(35) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(36) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(37) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(38) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(39) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(40) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(41) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(42) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(43) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(44) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(45) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(46) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(47) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(48) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(49) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(50) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(51) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(52) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(53) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(54) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(55) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(56) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(57) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(58) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(59) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(60) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(61) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(62) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(63) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(64) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(65) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(66) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(67) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(68) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(69) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(70) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(71) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(72) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(73) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(74) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(75) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(76) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(77) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(78) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(79) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(80) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(81) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(82) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(83) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(84) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(85) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(86) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(87) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(88) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(89) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(90) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(91) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(92) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(93) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(94) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(95) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(96) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(97) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(98) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(99) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(100) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(101) : error A2044:invalid character in file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(102) : fatal error A1012:error count exceeds 100; stopping assembly
Project : error PRJ0019: A tool returned an error code from "Assembling..."
Build log was saved at "file://c:\Users\Andre\Desktop\orange\orange\Debug\BuildLog.htm"
orange - 13 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thank you for any help you can give me

Is This A Good Question/Topic? 0
  • +

Replies To: Simple input and output

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Simple input and output

Posted 01 February 2013 - 02:54 PM

Try modifying to this:

include io.h         ;your header file
includelib io.lib    ;lib file in which the functions reside

Was This Post Helpful? 0
  • +
  • -

#3 andre1011  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 12-January 11

Re: Simple input and output

Posted 01 February 2013 - 03:59 PM

That solved part of the problem down to 7 errors now

here is the updated code
;Example assembly language program that adds two numbers
.586
.MODEL FLAT
includelib io.lib                    ;header file for input/output
.STACK 4096

.DATA
  number1    DWORD   ?
  number2    DWORD   ?
  prompt1    BYTE    "Enter the first number ",0
  prompt2    BYTE    "Enter the second number ",0
  string     BYTE    40 DUP (?)
  resultLbl1 BYTE    "The sum is ",0
  sum        BYTE    11 DUP (?) 
   
.CODE
   _MainProc  PROC 
        input  prompt1,     string, 40          ;read ASCII characters
        atod   string                           ;convert string to integer
        mov    number1,     eax                 ;store in memory
        
        input  prompt2,     string, 40          ;repeat for second number
        atod   string 
        mov    number2,     eax 
        
        mov    eax,         number1             ;first number to EAX
        add    eax,         number2             ;add second number
        dtoa   sum,         eax                 ;convert to ASCII characters
        output resultLbl1,  sum                 ;output label and sum
        
        mov    eax,         0                   ;exit with return code 0
        ret
   _MainProc ENDP
END                                             ;end of source code




here is the new error

------ Build started: Project: orange, Configuration: Debug Win32 ------
Assembling...
Assembling: .\bobby.asm
.\bobby.asm(18) : error A2008:syntax error : input
.\bobby.asm(19) : error A2008:syntax error : atod
.\bobby.asm(22) : error A2008:syntax error : input
.\bobby.asm(23) : error A2008:syntax error : atod
.\bobby.asm(28) : error A2008:syntax error : sum
.\bobby.asm(29) : error A2008:syntax error : output
Project : error PRJ0019: A tool returned an error code from "Assembling..."
Build log was saved at "file://c:\Users\Andre\Desktop\orange\orange\Debug\BuildLog.htm"
orange - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Simple input and output

Posted 01 February 2013 - 04:03 PM

Why did you replace the line rather than adding..?
Was This Post Helpful? 0
  • +
  • -

#5 andre1011  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 12-January 11

Re: Simple input and output

Posted 02 February 2013 - 08:45 AM

I thought your way was the correct way, but I tried putting the original included above the modified one and got more errors

Right now I am failing on an input statement I got right out of the book

input prompt1, string, 40 ;read ASCII characters

error A2008:syntax error : input

this line of code should work but it does not
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Simple input and output

Posted 02 February 2013 - 08:54 AM

I suspect it should be two separate lines:

output prompt1
input string, 40

Was This Post Helpful? 0
  • +
  • -

#7 andre1011  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 12-January 11

Re: Simple input and output

Posted 02 February 2013 - 09:09 AM

View Postandrewsw, on 02 February 2013 - 07:54 AM, said:

I suspect it should be two separate lines:

output prompt1
input string, 40


No luck, MASM 32 acts like it does not know what "input" and "output" keywords are.
Was This Post Helpful? 0
  • +
  • -

#8 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: Simple input and output

Posted 03 February 2013 - 09:17 AM

input and output are not keywords but macros. MASM is case sensitive, if it is called Input by the author, then you must also use Input. The book you are using is old and outdated I forgotten the name of the book, but over the years many folks had problems with it. You would be better off using the functions from the MASM32 library.

Just noticed. You are using .586 but are using the flat memory model - we don't use this nowadays.
Change this:
.586
.MODEL FLAT
INCLUDE io.h                     ;header file for input/output
.STACK 4096

to this:
.586
.model flat, stdcall                      ; 32 bit memory model
option casemap :none    

INCLUDE io.h 
include io.lib


Try assembling and see what happens.
Was This Post Helpful? 1
  • +
  • -

#9 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Simple input and output

Posted 03 February 2013 - 09:58 AM

Quote

INCLUDE io.h
include io.lib

Is the include statement not case-sensitive?
Was This Post Helpful? 0
  • +
  • -

#10 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: Simple input and output

Posted 03 February 2013 - 10:04 AM

No not case sensitive
Was This Post Helpful? 1
  • +
  • -

#11 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Simple input and output

Posted 03 February 2013 - 10:08 AM

View PostGunnerInc, on 03 February 2013 - 10:04 AM, said:

No not case sensitive

Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1