-1

So I'm trying to learn assembler and I'm using z390 as an emulator(not my choice) and I'm having a great deal of difficulty. I was hoping for some help because I have ALOT of errors.

Here's the assignment: assignment

So I took the college try at it and got this:

FIRST    CSECT
         BALR  12,0
         USING BASE,12
* FIRST VOLUME BEING CALCULATED ------------------------
         L     R2,L1         STORE L1 IN REG 2.
         L     R3,W1         STORE W1 IN REG 3.
         L     R4,H1         STORE H1 IN REG 4.
         MR    R1,3          MUTIPLY CONTENTS OF REG 2. BY REG 3. STORE CONTENTS IN REG 2.
         M     R1,H1         MUTIPLY CONTENTS OF REG 2. BY H1.    
         ST    R2,VOL1       STORE RESULT OF VOLUME IN VOL1.
* SECOND VOLUME BEING CALCULATED ------------------------
         L     R2,L1         STORE L1 IN REG 2.(UNCHANGED FROM BEFORE)
         M     R1,DBL        DOUBLES REG 2. VALUE
         ST    R2,L2         STORE DOUBLED LENGTH IN L2
         M     R2,DBL        DOUBLES REG 3. VALUE
         ST    R3,W2         STORE DOUBLED WIDTH IN W2
         M     R3,DBL        DOUBLES REG 4. VALUE
         ST    R4,H2         STORE DOUBLED HEIGHT IN H2
         MR    R1,3          MUTIPLY CONTENTS OF REG 2. BY REG 3. STORE CONTENTS IN REG 2.
         M     R1,H2         MUTIPLY CONTENTS OF REG 2. BY H1.    
         ST    R2,VOL2       STORE RESULT OF VOLUME(DOUBLED) IN VOL2.
* DIFF. BETWEEN BOTH ------------------------
         L     R2,VOL1      LOAD VOL1 INTO REG. 2.
         S     R2,VOL2      SUBTRACT R2 FROM VOL2.
         ST    R2,DIF       STORE THE RESULT.
* LABLES ------------------------
L1       DC    F'2'         LENGTH - 2
W1       DC    F'2'         WIDTH - 2
H1       DC    F'2'         HEIGHT - 2
DBL      DC    F'2'         CONSTANT TO DOUBLE ALL VALUES.
VOL1     DS    F            STORES VOLUME 1. - NON DOUBLED.
VOL2     DS    F            STORES VOLUME 2. - DOUBLED.
L2       DS    F            DOUBLED LENGTH
W2       DS    F            DOUBLED WIDTH
H2       DS    F            DOUBLED HEIGHT
DIF      DS    F            DIFF. BETWEEN VOL1 AND VOL2
*
*

So I thought that this was it because I understand the concept of everything here, but Z390 gives me this output:

Enter command or help
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
*** 02/06/17 18:26:24 CMD task started
C:\Program Files (x86)\Automated Software Tools\z390>CD \Program Files (x86)\Automated Software Tools\z390\
C:\Program Files (x86)\Automated Software Tools\z390>ASMLG "C:\Users\Owner\Desktop\New folder\SHELL" TRACE CON
C:\Program Files (x86)\Automated Software Tools\z390>rem asmlg assemble, link, and go from mlc to 390 execution 
C:\Program Files (x86)\Automated Software Tools\z390>echo off 
18:26:24 SHELL     MZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_73 02/06/17
AZ390E error  98         (1/3)3      USING BASE,12
AZ390E error 198         (1/5)5            L     R2,L1         STORE L1 IN REG 2.
AZ390E error 198         (1/6)6            L     R3,W1         STORE W1 IN REG 3.
AZ390E error 198         (1/7)7            L     R4,H1         STORE H1 IN REG 4.
AZ390E error 198         (1/8)8            MR    R1,3          MUTIPLY CONTENTS OF REG 2. BY REG 3. STORE
AZ390E error 198         (1/9)9            M     R1,H1         MUTIPLY CONTENTS OF REG 2. BY H1.
AZ390E error 198       (1/10)10            ST    R2,VOL1       STORE RESULT OF VOLUME IN VOL1.
AZ390E error 198       (1/12)12            L     R2,L1         STORE L1 IN REG 2.(UNCHANGED FROM BEFORE)
AZ390E error 198       (1/13)13            M     R1,DBL        DOUBLES REG 2. VALUE
AZ390E error 198       (1/14)14            ST    R2,L2         STORE DOUBLED LENGTH IN L2
AZ390E error 198       (1/15)15            M     R2,DBL        DOUBLES REG 3. VALUE
AZ390E error 198       (1/16)16            ST    R3,W2         STORE DOUBLED WIDTH IN W2
AZ390E error 198       (1/17)17            M     R3,DBL        DOUBLES REG 4. VALUE
AZ390E error 198       (1/18)18            ST    R4,H2         STORE DOUBLED HEIGHT IN H2
AZ390E error 198       (1/19)19            MR    R1,3          MUTIPLY CONTENTS OF REG 2. BY REG 3. STORE
AZ390E error 198       (1/20)20            M     R1,H2         MUTIPLY CONTENTS OF REG 2. BY H1.
AZ390E error 198       (1/21)21            ST    R2,VOL2       STORE RESULT OF VOLUME(DOUBLED) IN VOL2.
AZ390E error 198       (1/23)23            L     R2,VOL1      LOAD VOL1 INTO REG. 2.
AZ390E error 198       (1/24)24            S     R2,VOL2      SUBTRACT R2 FROM VOL2.
AZ390E error 198       (1/25)25            ST    R2,DIF       STORE THE RESULT.
18:26:25 SHELL     MZ390 ENDED   RC=12 SEC= 0 MEM(MB)= 38 IO=232
Press any key to continue . . . 
C:\Program Files (x86)\Automated Software Tools\z390>exit
*** 02/06/17 18:26:25 CMD task ended TOT SEC=1 TOT LOG IO=30

So pretty much I've been trying to figure out what I'm doing wrong for an hour, and so I turn to you guys / gals. So what the **** am I doing wrong?

Updated code, still getting errors on line 9,20?

FIRST    CSECT
         BALR  12,0
         USING BASE,12
BASE     L     3,L1         R3 = LENGTH OF BOX.
         L     5,W1         R5 = WIDTH OF BOX.
         L     7,H1         R7 = HEIGHT OF BOX.
         MR    2,5          HEIGHT OF BOX X WIDTH OF BOX.
         M     2,H1         RESULT OF MUTIPLY X HEIGHT OF BOX.    
         ST    3,VOL1       R2 = ALL HEIGHT X WIDTH X HEIGHT.

         L     3,L1         R3 = LENGTH OF BOX.
         M     2,DBL        MUTIPLY LENGTH OF BOX BY 2.
         ST    3,L2         R3 = LENGTH OF BOX X 2. 
         M     4,DBL        MUTIPLY WIDTH OF BOX BY 2.
         ST    5,W2         R5 = WIDTH OF BOX BY 2.
         M     6,DBL        MUTIPLY HEIGHT OF BOX BY 2
         ST    7,H2         R7 = HEIGHT OF BOX X 2
         MR    2,5          MUTIPLY LENGTH OF BOX (DOUBLED) BY WIDTH OF BOX(DOUBLED)
         M     2,H2         MUTIPLY RESULT BY HEIGHT OF BOX (DOUBLED)   
         ST    3,VOL2       R3 = LENGTH X WIDTH X HEIGHT
         L     3,VOL2       R3 = VOLUME OF FIRST BOX.
         S     3,VOL1       FIRST VOLUME - SECOND VOLUME(DOUBLED)
         ST    3,DIF        R3 = DIFF. BETWEEN VOLUMES.
L1       DC    F'2'         LENGTH = 2
W1       DC    F'2'         WIDTH = 2
H1       DC    F'2'         HEIGHT = 2
DBL      DC    F'2'         CONSTANT VALUE = 2
VOL1     DS    F            STORAGE FOR FIRST VOLUME (NON-DOUBLED)
VOL2     DS    F            STORAGE FOR SECOND VOLUME (DOUBLED)
L2       DS    F            LENGTH(DOUBLED)
W2       DS    F            WIDTH(DOUBLED)
H2       DS    F            HEIGHT(DOUBLED)
DIF      DS    F            STORAGE FOR DIFFERNCE IN VOLUMES.
*
*
         END   FIRST

(Updated with better comments as suggested by user.)

New Error???

16:08:37 SHELL     EZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_73 02/08/17
EZ390I Copyright 2011 Automated Software Tools Corporation
EZ390I z390 is licensed under GNU General Public License
EZ390I program = C:\Users\Owner\Desktop\New folder\SHELL.390
EZ390I options = 
EZ390I Trace Table Entry      800FFFB0 5050C066     ST   
EZ390I Trace Table Entry      800FFFB4 5C60C056     M    
EZ390I Trace Table Entry      800FFFB8 5070C06A     ST   
EZ390I Trace Table Entry      800FFFBC 1C25         MR   
EZ390I Trace Table Entry      800FFFBE 5C20C06A     M    
EZ390I Trace Table Entry      800FFFC2 5030C05E     ST   
EZ390I Trace Table Entry      800FFFC6 5830C05E     L    
EZ390I Trace Table Entry      800FFFCA 5B30C05A     S    
EZ390I Trace Table Entry      800FFFCE 5030C06E     ST   
EZ390E error  11 ABEND PSW=07052600 800FFFD2 F6F600000002 ????? ABEND S0C1
 R0-R3 F4F4F4F4800FFF88 F4F4F4F400002300 F4F4F4F400000000 F4F4F4F400000038
 R4-R7 F4F4F4F400000000 F4F4F4F400000004 F4F4F4F400000000 F4F4F4F400000004
 R8-RB F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4
 RC-RF F4F4F4F4800FFF8A F4F4F4F400002100 F4F4F4F400002018 F4F4F4F4800FFF88
EZ390E error  12 program aborting due to abend S0C1
EZ390I instructions/sec     = 333
EZ390I total errors         = 1
16:08:37 SHELL     EZ390 ENDED   RC=16 SEC= 0 MEM(MB)= 18 IO=37 INS=21
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Frank
  • 75
  • 2
  • 13
  • What's "line 9,22"? Can you post the assembly listing? – Yuri Steinschreiber Feb 07 '17 at 02:25
  • 4
    Need to see the error message and the line. You have no "exit" from your code, so control will run into your constants and data, so exciting things would happen. You have no saving of the calling program's (the OS's) registers. Your comments need a lot of work. The point is not to describe the instructions, but describe what you are doing (so that the next person along knows what was being attempted). To just describe, and describe both load and store as "store", does nothing. – Bill Woodger Feb 07 '17 at 12:14
  • This is my first attempt at writing any assembler code, I'm a high level programmer so this is a strange concept to me, I will work on my comments, thank you. Line 9 and 20* (not 22) are as follows: `M 2,H1 MUTIPLY CONTENTS OF REG 3. BY H1.` `M 2,H2 MUTIPLY CONTENTS OF REG 3. BY H1.` Error on both lines are: `MZ390E error 11` – Frank Feb 07 '17 at 13:38
  • I have commented my code a bit more extensively, please feel free to give me more constructive criticism on it! – Frank Feb 07 '17 at 13:51
  • 3
    @Frank As Bill says, 'LOAD VALUE OF L1 INTO REG 3' is a bad comment - we can see that. A good comment is 'R3 = length of box'. Also you can use better labels (variable) e.g. use length1 instead of L1, volume1 instead of VOL1 – Steve Ives Feb 07 '17 at 13:55
  • Oh, I completely understand what you're saying now. Thank you, for expanding on Bill's idea more! – Frank Feb 07 '17 at 13:57
  • @Steve/ @Bill - updated my comments again, let me know what you guys think! – Frank Feb 07 '17 at 14:15
  • Comments a massive improvement. One thing to watch is the "continuation column". Your longest comments have gone to column 72 (or beyond) and that, since continuations are strict on the format of the continued lines, is giving you the "error 11". – Bill Woodger Feb 07 '17 at 17:41
  • You still have no "end" for your program. Once you get a clean assemble, you will have problems with execution. You should start a new question if you need assistance on that. – Bill Woodger Feb 07 '17 at 17:42
  • The continuation problem is reported for the continued line (because it is that line where the format is wrong, the assembler doesn't know that indicating a continuation was the error), so the error line is the one before. – Bill Woodger Feb 07 '17 at 17:46
  • 1
    And if you don't have enough space for a comment, don't use the continuation. Just start the next line with an asterisk is column one, and then spaces to line up with the starting part of the comment. Stick in blocks like that where needed. Comments should provide "this is what I think I'm doing" and the code provides "this is what I'm actually doing". With many different ways to code something, simply repeating the assembler code in words reveals nothing to anyone (which could be you, when you look at the code later). – Bill Woodger Feb 07 '17 at 18:26
  • I have fixed line 9 and 20 but now the compiler throws me a NEW error, and I just have no clue at all. It's after the `ST` but there's nothing after that, just variables being declared?? Check new updated code ^ I can't figure this out. – Frank Feb 08 '17 at 21:16
  • 2
    You've now got a clean assemble, and the program is executing. As I've already suggested, I think you now need a new question. The answer to what is going on in already in my earlier comments, twice. What is after the ST in memory? How do you intend your program to "get back to the operating system". A S0C1 is an Operation Exception. Attempting to execute something which is not a valid machine instruction. – Bill Woodger Feb 08 '17 at 23:44
  • 2
    There's a difference between a compiler and an assembler. In an assembler, each OP-code and its parameters are just converted to machine instructions. Each storage definition with a value is simply given that value. OP-codes and storage just snuggle next to each other. A compiler takes high-level stuff and generate lower-level stuff (machine-code or an intermediate code). You are using an Assembler to write code. It just appears exactly as you code it. You have to code for *everything*, although there are some macros (which just generate code) to help. – Bill Woodger Feb 08 '17 at 23:48
  • I got the solution guys. It was actually an issue with the "Shell" my instructor provided, I emailed him about it and he corrected it. I put my code into the new "Shell" and it worked. I really do appreciate all your help guys and constructive criticism. In the Shell was a an "Exit" for the program and all of that we haven't learned yet that he provided. – Frank Feb 09 '17 at 15:29

2 Answers2

1

I don't have z390 installed at the moment so I can't tell you how to make it print more meaningful error messages, but looking at your code I can immediately see that:

  • BASE is undefined (the way you establish addressability it must follow the BALR 12,0)

  • R1, R2 etc. are undefined (you need a series of R1 EQU 1, R2 EQU 2 etc. statements.)

You probably need to spend a bit more time learning the meaning of names in Assembler.

Yuri Steinschreiber
  • 2,648
  • 2
  • 12
  • 19
  • What if I didn't use R1 and such and just used numbers instead? `L 1,L1` which should load `L1` into Register 1 because of the RX format right? – Frank Feb 07 '17 at 00:04
  • Also I think I get what you meant so I added this: `BASE L 2,L1 STORE L1 IN REG 2.` – Frank Feb 07 '17 at 00:10
  • 1
    Right, you don't need to use symbolic names for registers - numbers work just as well. – Yuri Steinschreiber Feb 07 '17 at 00:41
  • So in that case I fixed all my errors so far. The only ones I have left are on lines 9 and 20, for the multiply function. I understand the whole even / odd pair thing and how it applies to multiplication in assembler. So if my my one number is in`Register 2` and my other is a variable stored in `H1` then why can't I do `M 1,H1` without it giving me an error? – Frank Feb 07 '17 at 00:46
  • 1
    Yes you need an even/odd pair of registers, that is, the register you specify in the instruction must be *even* and the entire operand is in the even register and the following odd register. So for example use registers 0 and 1 - zero register 0, load your word-sized operand into register 1, and use `M 0,H1` – Yuri Steinschreiber Feb 07 '17 at 00:52
  • So how would I work that for register 2, since it's already an even register? Or it's not possible? – Frank Feb 07 '17 at 00:58
  • 1
    You don't need to zero the even register, that was just overdefensive. – Yuri Steinschreiber Feb 07 '17 at 00:59
  • 2
    No, it's not possible. The multiplicand must be in an odd register. Read *Principles of Operation*, it's a very lucid exposition. – Yuri Steinschreiber Feb 07 '17 at 01:00
  • I've posted my updated code, but I'm still getting errors? ideas?? Thank you so much for your help, seriously! – Frank Feb 07 '17 at 01:15
1

I can see that you forgot to put an exit to your program. It was executing the instructions in sequence and ST 3,DIF was the last valid instruction. After that you have a some DC, which is basically data. When the CPU executes the store mentioned above, it will fetch the "next instruction" in sequence and finds the constant, giving an "OC1" abend or, better explained, an "invalid operation exception". After the ST 3,DIF you should give back control to the operating system, by issuing an RETURN macro instruction.