4 Replies - 725 Views - Last Post: 02 April 2018 - 10:15 AM

#1 howerj   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 18

Specified counting program errors

Posted 28 March 2018 - 01:57 PM

I tried to write a program that will allow the user to specify how many times the program will loop and display the title of the program (including name in the title). Printing from inside the loop a string and count. I keep getting "error: comma, colon, decorator or end of line expected after operand" and I do not know what to do. Any help would be much appreciated!
DATA:

title                  DB                   "NAME_TITLE", 10h, "$"

inp                               DB                   "HOW MANY NUMBERS", 10h,10h,10h,"$"

inpnum                        DB                   "ENTER NUMBER", 10h,10h,"$"

n                                  DB                   ?

MAIN:

mov                 ah, 9

mov                 dx, offset title

int                    21h

mov                 ah, 9

mov                 dx, offset inp

int                    21h

str                    al, n                             ; save the counter into n

mov                 cx,al                            l loop counter, initialize to number entered by user

LOOP:

bez                  cx, END                                  ; if cx is 0 then exit loop

; ask user to input a number

mov                 ah, 9

mov                 dx, offset inpnum

int                    21h

;display number

mov                 ah, 2

mov                 dx, al

int                    21h

;display count

mov                 ah, 2

mov                 dx, cx

int                    21h

dec                  cx                                            ; increment loop counter

b                      LOOP

END:

_exit


Is This A Good Question/Topic? 0
  • +

Replies To: Specified counting program errors

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14862
  • View blog
  • Posts: 59,301
  • Joined: 12-June 08

Re: Specified counting program errors

Posted 28 March 2018 - 02:00 PM

what is this? FORTRAN?
Was This Post Helpful? 0
  • +
  • -

#3 howerj   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 18

Re: Specified counting program errors

Posted 28 March 2018 - 03:12 PM

View Postmodi123_1, on 28 March 2018 - 02:00 PM, said:

what is this? FORTRAN?


It is Assembly.

Based off of the MASM program attached.

https://imgur.com/a/lxaIN
Was This Post Helpful? 0
  • +
  • -

#4 Ornstein   User is offline

  • New D.I.C Head

Reputation: 11
  • View blog
  • Posts: 20
  • Joined: 13-May 15

Re: Specified counting program errors

Posted 01 April 2018 - 04:33 AM

The switches you use when running MASM on the command line (/coff etc) can have an effect on what is/isn't valid in the code. The linker can add even more problems and confusion to the mix.

I've not used MASM for a long time so I could be wrong here, but much of your code isn't recognisable to me as MASM-compatible. Do you have a link to where you found it? That "DATA:" label, for example.

You may want to just find a MASM-specific assembly tutorial and start from the bottom - to get a feel for the format of the code and such. 15+ years ago I learned from Iczelion's tutorials and they still seem to be the most relevant search result on Google. You may be able to find something more up-to-date elsewhere.
Was This Post Helpful? 0
  • +
  • -

#5 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,107
  • Joined: 03-April 12

Re: Specified counting program errors

Posted 02 April 2018 - 10:15 AM

It looks like "DOS assembly" - that is assembly for PC before Windows 3.1 or something.
I'm not really sure, because I have never really learned Intel x86 assembly, but somehow looks familiar from a distant past...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1