Solved

Does anyone know assembly languge?

Posted on 1997-11-05
10
673 Views
Last Modified: 2010-07-27

I am currently working on a problem in assembly....and I was wondering
if you could help me....Here is the question.....
Insurance sales: Find the insurance agent who sold the most premiums for
the year. The format for the input consists of the following:

columns            Field Names
01-15               Insurance agent
16-18               Policy premium
25-27               Number of policies sold

Input data:

AGENT               PREMIUM PER POLICY        POLICIES SOLD
Roy Marx             $750                       100
Cathy Reed            423                       231
Tex Lacey             214                       175
Phillip Nye           486                       109

There are more ...but I think you get the general idea..it goes onto say

PROCESSING FUNCTIONS:
Find the top agent of the year. Determins who sold the most premiums.
Premiums sold= premium per policy * policies sold.

PROGRAM OUTPUT(REPORT):
        Produce a report listing each agent and the premium sold by that
agent.At the end of the report, print name of the top sales agent and
the premium sold.

It would also like to have the program modified to include the agent
with the lowest sales for the year.

So I guess what I am asking I am not real sure how to set this problem
up....could you please help me....? Thanks for any info....
                        Saphire
0
Comment
Question by:Saphire38
10 Comments
 
LVL 1

Expert Comment

by:kburns102197
ID: 1256157
1. What language - (target processor)  x86?
2. What memory model - small?
3. Do you need a C- assembly interface? (Will you be calling the assembly language routine from C)
4. Is inline assembly in C or C++ acceptable?
5. Is this a console app under Windows? (Whats the output device)
0
 

Author Comment

by:Saphire38
ID: 1256158
Question 1..it is assembly language for the IBM system 370 modular approach..
Question 2...Not sure what you mean....?
Question 3...No I will not be calling it from C...
Question 4...would it be the same as a PC 370?
Question 5...Not sure what you mean....?

This is the program that I am running this assembly problem on...
 
READ.ME PC/370 Release 4.2 Installation Guide

Copyright 1988 Donald S. Higgins

                                  Don Higgins
                                  6365 - 32 Avenue North
                                  St. Petersburg, Florida 33710
                                  January 5, 1988

PC/370 users:

Welcome to release 4.2 of the PC/370 cross assembler and emulator
package!  You are encouraged to copy and share this package with other
users on the condition that the package is not distributed in modified
form, and that no fee is charged.  If you find the PC/370 product
useful, send 45 dollars to the address above to register as a user and
to support continued shareware maintenance and enhancements.
Registered users will receive notices of future releases.  The product
is distributed on an as is basis with no implied warranties.  However,
requests for fixes and enhancements from registered users are given
priority for inclusion in future releases.  Currently planned future
enhancements are as follows:

  1.  Assembler H support with integrated macros.

  2.  Expanded memory support using protected mode on 80286/80386
      running under native OS/2.

  3.  Improved 370 emulation performance using additional math co-
      processor assists for packed decimal and native 80386 32 bit
      instructions.  (Note the current speed of the PC/370 emulator on
      a 16 MHZ 80386 is in the range of 25,000 IBM 370 instructions
      per second or 0.025 MIP's.)

The major features included since PC/370 release 3.2 are as follows:

  1.  Micro Focus COBOL/2 Extended Memory (XM) protected mode calls to
      PC/370 assembler subroutines are supported on 80286 and 80386
      systems.  XM supports up to 16MB of real memory usable by COBOL
      and PC/370 assembler subroutines.  See USER.DOC for more
      information.  This facility requires use of new resident option
      of emulator, and option B of linker to create BIN type module.

  2.  The following PC/370 supervisor calls have been added:

      a.  Svc 36 reloads program into specified area of memory.
      b.  Svc 37 defines user exits for supervisor calls.

  3.  The SPIE svc 14 has been enhanced to create program
      interruption element control block and to pass sufficient
      information to support transparent program check recovery.

  4.  At entry to main programs, register 1 now points to standard
      MVS parameter list address, which in turn points to half
      word parm length followed by EBCDIC parameters passed from
      MS-DOS command line.

  5.  An optional hardware assist for the CVB and CVD instructions
      is included which requires the 80x87 math co-processor and
      can speed up the instructions by up to a factor of 4 for
      large numbers.  The floating point option P controls whether
      the assist is activated when 80x87 is installed.

  6.  The L370 linkage editor now supports option U to allow
      unresolved references.

  7.  The emulator debug facility now has option to restore all
      trace points at any point during execution by repeated use
      of K command.  An optional version of emulator is also included
      with the name E370P42.EXE which does not include interactive
      debug or ASSIST facilities.  This version saves space, but
      should only be used with fully tested production programs.
      To use this version, make it resident by executing it.

  8.  The PC/370 emulator E370R42.EXE can now be made resident by
      simply executing it directly.  This eliminates the time required
      to load the emulator for each execution of a PC/370 assembler
      program.  In addition, a common system queue area (SQA) memory
      can be allocated in the resident emulator address space to be
      shared by assembler subroutines called from COBOL.  The size of
      the SQA is specified in hex paragraphs as the only parm.  The
      default is 10 hex or 256 byte SQA.  Assembler subroutines called
      from COBOL can now perform file I/O and dynamic memory
      management using the common SQA memory.

  9.  The 370 cross assembler A370.EXE now supports the COPY statement
      to include commonly used DSECT's, EQU's, or code.  Common copy
      files such as IHADCB.CPY for a DSECT of a DCB, EQUREGS.CPY for
      R0-R15, and EQUSVCS.CPY for equates for all of the PC/370
      supervisor calls are included.

 10.  The following fixes have been included:

      a.  CVB error when input field contained negative 0.
      b.  SRP error when second field contained more than 6 bit #.
      c.  Program check on executed instruction did not store
          correct address of next instruction following execute.
      d.  EBCDIC to ASCII translate table did not correctly handle > {
          and [ characters.
      e.  Text file with LRECL=1 caused incorrect record move.
      f.  Operand of ORG statement can now be CSECT or DSECT as
          well as relative symbol within CSECT or DSECT.
      g.  File open svc 1 now takes error exit for file not found and
          reg 0 and 1 now contain error code at entry to error exit
          (See LIB\SYNERROR.ALC for subroutine to decode errors).

For brief description of changes in previous releases since 1981,
see DOC\HISTORY.DOC.  Thanks to Jacques Roy, a macro preprocessor
M370.COM (written in 370 assembler) has been included since PC/370
release 3.2 along with a set of MVS compatible macros including DCB,
OPEN, CLOSE, GET, PUT, READ, WRITE, WTO, WTOR, LINK, LOAD, GETMAIN,
etc.  If you use the macro preprocessor, register as a macro user and
support future enhancements, by sending a registration fee of $20. to:

        Jacques Roy
        XL Software Inc.
        1000 St-Jean Baptiste #120
        Quebec, Canada G2E-5G5

To install the PC/370 system on a hard disk and run the demo programs,
copy the file BAT\INSTALL.BAT to separate hard disk directory and
execute it.  INSTALL requires two parameters, the first is the drive
containing the distributed floppy disk and the second is the hard disk
drive.  Command C>INSTALL B C will install the system on hard disk C
reading files from drive B with prompts for each volume if more than
one.  The install file defines a root directory \R42 which contains
all of the executable programs and system files required by the PC/370
facilities.  The following sub-directories are also created:

  1.  \BAT  - contains batch files which can be executed without
              any parameters after setting current directory to
              R42.

  2.  \LIB  - contains ALC source code for PC/370 system
              subroutines.

  3.  \CPY  - contains CPY source code for ALC source COPY
              includes.

  4.  \MAC  - contains MAC and MLC source code for macro pre-
              processor.

  5.  \CBL  - contains CBL Micro Focus VS COBOL demo program source
              code along with demo PC/370 assembler subroutine
              source code.

  6.  \DOC  - contains machine readable PC/370 documentation.  Read
              DOC\INTRO.DOC for PC/370 overview and more
              information on the other component of the package.

  7.  \DEMO - contains demo program ALC source code.

  8.  \UTIL - contains utility program ALC source code.


Hope you enjoy PC/370!  Feedback on your usage and/or
evaluation of the product is highly encouraged.

Sincerely,



Don Higgins, CCP, CDP

___________

IBM          - trademark of International Business Machines
COBOL/2, XM  - trademarks of Micro Focus Inc.
MS-DOS       - trademark of Microsoft
0
 
LVL 3

Expert Comment

by:LucHoltkamp
ID: 1256159
The easiest way is:
Write it in C, and compile it to assembly, optimise the result.
.luc.
0
 

Expert Comment

by:Levin
ID: 1256160
Why use Assembly?

C is (almost) as fast.
The difference is so small you probably won't notice it.

I once wrote a Assembly function and a C function just to compare. I thought I was pretty god at assembler but GCC beat me.
(Probably because I wrote 486-optimized code and gcc Pentium code.)

But my point is -- use C.

/Johan
0
 
LVL 1

Expert Comment

by:kburns102197
ID: 1256161
It doesn't appear the that your PC/370 emulator came with a C cross compilier based on what I see above.  You do have a cross assembler to do this project.  I would suggest 1) that you look at the ALC source code example. 2) Get some documentation on IBM 370 assembly language because you need to know the instruction set 3) re-post your question in the general programming section as an IBM 370 assembler question.   I could offers assistance to you on Intel or Motorola assembly but not IBM 370.  Good luck..
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Saphire38
ID: 1256162
Thank you for all your help....
0
 

Expert Comment

by:richcasto
ID: 1256163
Is this an assignment for class, perhaps?
0
 

Author Comment

by:Saphire38
ID: 1256164
yes it is ....i don't know how to get it started ....
0
 
LVL 1

Accepted Solution

by:
meessen earned 100 total points
ID: 1256165
Start by writing in clear text what are the steps you need to do the requested processing.

Then write it in a programming language you know the best: Pascal, Basic, C.

Later step is to translate each instruction into assembly code by hand.

The first step is the hardest. it may be split in multiple tasks;
1. understand the question: What is the requested output ?
2. identify and understand the given data: What is the given input ?
3. find how you can answer the request: What operation is needed on the input data to yield the output data ?
(This is just giving the major processing steps, a sort of method description: no details).
4. refine your method description by identifying needed data like counters for instance, etc.

----------------------

In your problem the input is clearly specified and obvious.
The output is also specified but less precisely.
You also have a serious hint on the processing steps to do if you search for the top agent.

The method is the following:

print out the list of agents+premium sold
Search the top agent

Here one needs a litle programming experience to know how to print a list or search for a maximum value in a list.
You have to go at each line in the input and print out the name and the premium sold.
For searching you also have to examine each line(entry) of the list. You could check if it's the biggest met so far, but what if there are many agents that qualify as top agents ?
So you should, in a first pass, compute the biggest premium in the list and in a second pass output all agents that match this premium. (a pass is a list scanning).
How to we find a biggest value in a list ?
use a variable holding the biggest value met so far. Initialize it with 0. When you scan the list, if a value is bigger than the variable content replace the variable content with the bigger value. At the end of the list, the variable content will be the biggest value.

Process;
let maxPremium be the maximum premium value met so far
let premiumSold be the premium sold of a given agent
intialize maxPremium to zero.
for each list entry
    set premiumSold to policyPrice*numberSold
    print agent and premiumSold
    if premiumSold is bigger than maxPremium then
         set maxPremium to premiumSold.

print top agent title
for each list entry
    set premiumSold to policyPrice*numberSold
    if premiumSold is equals maxPremium then
         print agentName

As you can see we combined the first printing loop and the maxPremium search. This is just to make it shorter. We could have  used two loops. The second pass is need though because we only know the biggest premiumSold at the end of the first pass.

To find the minimum premium sold and the lowest agent you need another variable holding the lowest value. You initialize it to the maximum value. But this is not always easy to know. You can initialize it to the premiumSold by the first agent. The same initialization value can be used for the maxPremium.

I guess you understood how to modify the high level code to find the minimum premium.
To print out the lowest agents you need a third pass that print out agents which premium is equal to the minPremium.


Ok. Now you have the first step done.
Now you go for step two and translate this psoeudo code into real code. Choose a language you are used to.
You will then need to solve some details like how to print names and numbers, how to get values from the entry fields etc.
But this is the core of your assignement.

I hope this brings you on track.
0
 

Author Comment

by:Saphire38
ID: 1256166
thank you very much for explaining this to me it is easier to understand now....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now