Hey guys... this is my first time working with assembler, so please be patient with me! I am currently taking a course in assembler and have had a couple of basic assignments so far (mainly number systems, adding subtracting, two's complements etc etc). This is my first major (you may think so!) programming assignment.

I have to read in from a file that has the following:
a car number -
the price of the car (in whole dollars) -
the tax on the car (in whole dollars) -
cost of the new car (in whole dollars)

In four colums, like this:
1 25250 1250 24908
2 #### ### ####
and so on.

I have to read from this file, computer some information, and print the result, all in assembler.

Below is my attempt at doing this - could i get some input - i have it working i think as when i read through my assist dump of the program i find the hex code for the value 25250 - so i am reading in correctly.
I just wanted to make sure the basics look good before i start trying to figure out the way i can do addition/subtraction/multiplication etc of different variables in different registers!

So thanks for any input - i would love to know if there would be a way i can read in from the file multiple times, using a loop (sory of like you can do with a while (eof) in c++).
Is this possible with assembler? Cant you use labels? Like DO1 ENDD01 etc.?

Any ideas?

Here the code so far:

*        1         2         3         4         5         6         7
         USING     ASSIGN2,1          Establish addressability
*         XPRNT     PGHDR,72
*         XPRNT     COLS,72
         XREAD     BUFFER,80          Reads in first line of input
         XDECI     2,BUFFER           stores car number in R2
         XDECI     3,0(,1)            stores price of car in R3
         XDECI     4,0(,1)            stores tax on car in R4
         XDECI     5,0(,1)            stores cost of new car in R5
         SR        6,6
         XDECO     2,CARNUM           STORES IN R2 IN CARNUM
         XDECO     3,PRICE            price of car
         XDECO     4,TAX              stores tax on car in TAX
         XDECO     5,NEWCOST          stores R5 in newcost
         A         6,PRICE            adds price to cost (r6)
         A         6,PREP             adds prep to cost (r6)
         A         6,TAX              adds tax to cost (r6)
         S         6,DISCNT           subtracts discount from cost
***********************STORAGE SPACE*******************************
COST     DS        CL12           TOTAL PRICE FOR CUSTOMER
PREP     DC        F'375'         PREP COST OF CAR
PCOST    DC        F'125'         PRESENT COST
DEALCST  DS        CL12           DEAL COST OF CAR
PROFIT   DS        CL12           PROFIT ON SALE OF CAR
*PGHDR    DC        C'1'
*         DC        CL55' '
*         DC        C'CAR SALES REPORT'
*COLS     DC        C'0'
*         DC        CL1' '
*         DC        C'CAR NUM'
*         DC        CL11' '
*         DC        C'CUSOMTER COST'
*         DC        CL30' '
*         DC        C'DEALER COST'
*         DC        CL47' '
*         DC        C'PROFIT'
CARNUM   DS        CL12           NUBER OF CAR
PRICE    DS        CL12           INITIAL PRICE OF CAR
TAX      DS        CL12           TAX ON SALE OF CAR
NEWCOST  DS        CL12           NEW COST OF CAR
         END       ASSIGN2

NOTE*** I have commented out the lines i have tried to get printing colum headers etc. But i keep getting a AS000 error on some of the lines - so once again, i would like basic info on if the code looks good, and if and how i could set up a loop to read to EOF ... if possible

Thanks folks.

Heres a quick update, i have continued working on the assignment and gotten a working loop. But am now concerned that for whatever reason the way i am reading the input file correctly - or the printing i am attempting is incorrect... i will post my entire code, but i will highlight parts which i think are the error striken ones... first off, my input file is this:

1 24250 1698 20600
2 15120 1058 12900
3 23640 1655 20100
4 19110 1338 16250
5 21820 1527 18550
6 44600 3122 37900
7 32700 2289 27800
8 35975 2518 30575

And my output file is attached...

Here is my code:

//Z109079A JOB ,'Tony Hogan',REGION=2048K,MSGLEVEL=(1,0)
         TITLE 'Tony H, CSCI360, 1, Assignment2'
* Name: ASSIGN2
*        1         2         3         4         5         6         7
         USING     ASSIGN2,15     Establish addressability
         XPRNT     PGHDR,72       Prints header
         SPACE     2              f
         XPRNT     PLINE,70       fffffffffffffffff
         XREAD     BUFFER,80      Reads in the first line
DO1      BC        B'0100',ENDDO1 f
         XDECI     2,BUFFER       Stores car # in R2
*         XPRNT     2,12
         XDECI     3,0(,1)        Stores price of car in R3
         XPRNT     3,12
         XDECI     4,0(,1)        Stores tax on car in R4
         XDECI     5,0(,1)        Stores cost of new car in R5
         SR        6,6            Sets R6 (customer cost) to 0
         XDECO     2,CAR          Stores R2 into the car #
         XDECO     3,PRICE        Stores R3 into price of car
         XDECO     4,TAX          Stores R4 into tax
         XDECO     5,NEWCOST      Stores R5 into new cost of car
         A         6,PRICE        Adds price to R6
         A         6,PREP         Adds prep to R6
         A         6,TAX          Adds tax to R6
         S         6,DISCNT       Subtracts discount from R6
         XPRNT     CDATA,5        prints the lines of data
         XREAD     BUFFER,80      reads the next line
         BC        B'1111',DO1    loops back to DO1
ENDDO1   DS        0H             end of my DO1 loop
         XDECO     6,COST         Stores R6 into customer cost
         BCR       B'1111',14
**************************** STORAGE AREA *****************************
PREP     DC        F'375'         Prep cost of car
DISCNT   DC        F'350'         Discount off of the car
PCOST    DC        F'125'         Present cost of car
BUFFER   DS        CL80           Allocated memory
COST     DS        CL12           Price customer will pay
DEALCST  DS        CL12           Dealer cost
PROFIT   DS        CL12           Profit the dealer made
CAR      DS        CL12           Car number
PRICE    DS        CL12           Price of car
TAX      DS        CL12           Tax on car
NEWCOST  DS        CL12           Cost of new car
PGHDR    DC        C'1'           Header
         DC        CL55' '        spaces
         DC        C'0CAR SALES REPORT'      title of report
PLINE    DC        C'0'           Columns
         DC        CL1' '         spaces
         DC        C'0CAR #'      car # colum header
         DC        CL11' '       spaces
         DC        C'0CUSTOMER COST'  column header
         DC        CL30' '        spaces
         DC        C'0DEALER COST'  column header
         DC        CL47' '       spaces
         DC        C'0PROFIT'     column header
CDATA    DC        C'0'           colum start point
         DC        CL1' '        spaces
         XPRNT     CAR,5          should print car # 1-8
         DC        CL11' '        spaces
         XPRNT     COST,5         cost of car
         END       ASSIGN2        end assign2

Please note - i am trying to print out in 2 ways ... after the XDECO to see what the value is of each register - but i dont get any values as you will see in my dump, and then when i print using the CDATA line, i still get weird values...

What could be causing this? Incorrect input from file (ie not being able to read/open the file) or am i being dump and trying to print variable data incorrect - or worse yet, did i store the values from registers to variables in storage wrong?

Any help...please would be great!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.