Need Interview FAQ's for Assembler

Ask/Clarify the questions on ASSEMBLER language.

Moderator: Moderator Group

Post Reply
kumar_log@hotmail.com
Member
Posts: 6
Joined: Wed Jan 28, 2009 7:08 pm
Location: Singapore

Need Interview FAQ's for Assembler

Post by kumar_log@hotmail.com » Wed Feb 04, 2009 1:21 am

Dear Friends,

I have attended few interview's for Assembler.

I have been asked few queston only as

1. Difference between DS & DC
2. Types of Instruction
3. Different data types
4. Types of registers R1-R16
5. How to call subprogram
6. Move command.

As i'm kind of beginner in assembler and able to manage this kind of basic question, able to clear them. I have some hand on experience on Assembler code, but not much exposure.

I would like to know some good inteview questions with answer's.

Any basic books (links) to start up with coding Assembler.

Pls help me out.

Thanks in Advance.
Thanks and Regards,
L.Kumar

nareshv_99
Member
Posts: 25
Joined: Sun Feb 05, 2012 10:59 pm
Location: Bangalore

Post by nareshv_99 » Tue Feb 07, 2012 11:48 pm

adding a few.. i had been asked to answer below ques..

1. how to move more than 256 chars to a filed ?
2.
var1 dc cl5'abcde'
var2 dc cl5'12345abcde'
write a instruction so that comparison between var1 and var2 should be true

3.
var1 dc cl5'abcde'
var2 dc cl5'12345abcde'
MVC var2,var2
what var2 will have ?
4.
var1 ds cl5'abcde'
can i define the var1 with the above instruction

other than this they asked me how TR instruction works and difference between TR and TRT

please add if anyone had faced any Assembler interview ques
Thanks!

nareshv_99
Member
Posts: 25
Joined: Sun Feb 05, 2012 10:59 pm
Location: Bangalore

Post by nareshv_99 » Tue Feb 07, 2012 11:54 pm

Any basic books (links) to start up with coding Assembler.

i found below links very very useful..
http://www.billqualls.com/
http://www.edwardbosworth.com/

book:
Assembler Language Programming: The IBM System/360 by
George Struble

very useful book for beginners.
enjoy maadi.. :D

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Feb 08, 2012 2:33 pm

nareshv_99 - What's the benefit of posting in a thread which is around more than 3 years old?
Regards,
Anuj

nareshv_99
Member
Posts: 25
Joined: Sun Feb 05, 2012 10:59 pm
Location: Bangalore

Post by nareshv_99 » Wed Feb 08, 2012 10:08 pm

yea.. totally agree and i didn't see the date when i was posting it..

if i'm not correct main aim first of this forum is sharing and learning..

so what i posted here was my real experience.. can you give a url or references where some posted some useful Assembler links and book names ?

you dont even find those Assembler question in the net..

FYI- i'm not posting for FREE DB2 E-BOOK..

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Feb 09, 2012 3:44 pm

Calm down ...:). The point is, if the thread is old and the original poster does not lurk around the forums - most of the times you are left with open ended questions, which is not good.

Here is kind of link you've asked for, from this forum: http://www.mainframegurukul.com/ibmmain ... 28ec18985d
Regards,
Anuj

BobC
Member
Posts: 3
Joined: Thu Aug 20, 2015 1:40 am
Location: California, USA

Re: Need Interview FAQ's for Assembler

Post by BobC » Thu Aug 20, 2015 5:25 am

kumar_log@hotmail.com wrote:Dear Friends,

I have attended few interview's for Assembler.

I have been asked few queston only as

1. Difference between DS & DC
2. Types of Instruction
3. Different data types
4. Types of registers R1-R16
5. How to call subprogram
6. Move command.

As i'm kind of beginner in assembler and able to manage this kind of basic question, able to clear them. I have some hand on experience on Assembler code, but not much exposure.

I would like to know some good inteview questions with answer's.

Any basic books (links) to start up with coding Assembler.

Pls help me out.

Thanks in Advance.
kumar_log@hotmail.com wrote:Dear Friends,

I have attended few interview's for Assembler.

I have been asked few queston only as

1. Difference between DS & DC
2. Types of Instruction
3. Different data types
4. Types of registers R1-R16
5. How to call subprogram
6. Move command.

As i'm kind of beginner in assembler and able to manage this kind of basic question, able to clear them. I have some hand on experience on Assembler code, but not much exposure.

I would like to know some good inteview questions with answer's.

Any basic books (links) to start up with coding Assembler.

Pls help me out.

Thanks in Advance.
1. DS means "Define Storage" it sets aside sufficient space for the variable(s) you describe as its parameters, but does NOT give them an initial value, whereas DC ("Define Constant") does initialize the memory it allocates.

2. Machine Instructions are classified by their purpose and datatype:
  • (a) General instructions -- perform fixed-point arithmetic and addressing using general-purpose registers, perform logical (Boolean) operations in registers or main memory, perform byte (character) operations in main memory

    (b) Decimal instructions -- perform arithmetic on packed decimal fields in main memory

    (c) Floating-point instructions -- perform floating-point arithmetic using floating-point registers

    (d) Control instructions -- privileged instructions not generally used by application programs (use macros instead)

    (e) Input/output operations -- perform I/O at the machine level. These are not used by applications, which use macros instead

    (f) Branching -- control non-sequential program flow
Note: there are also pseudo-instructions (a/k/a "Assembler Instructions"), whose purpose is to provide information to the Assembler itself. These include USING, DROP, CSECT, START, DSECT, etc.

3. Different data types
IBM mainframes support the following native data types:
  • (a) byte (character) data

    (b) half-word integer (16 bits, 1 sign bit and 15 data bits in two's-complement form)

    (c) full-word integer (32 bits, 1 sign bit and 31 data bits in two's-complement form)

    (d) Address data (32 bits, unsigned binary)

    (e) Single (a/k/a "Short") IBM Hexadecimal Floating Point; 4 bytes (32 bits): 1 sign bit, 7-bit characteristic**, and fraction of 6 hexadecimal digits)

    (f) Double (a/k/a "Long") IBM Hexadecimal Floating Point; 8 bytes (64 bits: 1 sign bit, 7-bit characteristic**and fraction of 14 hexadecimal digits

    (g) Quad (a/k/a "Extended") IBM Hexadecimal Floating Point; 16 bytes (128 bits): 1 sign bit, 7-bit characteristic**and fraction of 28 hexadecimal digits)

    (h) Single (a/k/a "Short") IEEE Binary Floating Point: 4 bytes (32 bits) with a sign of 1 bit, an exponent of 8 bits and a binary fraction of 23 bits

    (i) Double (a/k/a "Long") IEEE Binary Floating Point: 8 bytes with a sign of 1 bit, an exponent of 11 bits and a binary fraction of 52 bits.

    (j) Quad (a/k/a "Extended") IEEE Binary Floating Point: 16 bytes with a sign of 1 bit, an exponent of 15 bits and a binary fraction of 112 bits.
** the "characteristic" is a base-16 exponent in binary excess-64 format

4. Types of registers R1-R16
There are two types of registers: general purpose registers and floating-point registers.
  1. (a) General purpose registers are numbered 0 through 15 (e.g. R0 through R15, NOT R1-R16) and perform 32-bit arithmetic in either signed or unsigned modes, depending on the machine instruction used.

    (b) Floating-point registers are numbered 0 through 6, and are used in pairs, so only the even numbered register is referred to in the instruction.
5. How to call subprogram
Subroutines are not required to have parameters, but those that do are passed a list of addresses in main memory. The first address points to the first parameter, the second address points to the 2nd parameter, etc. The high-order bit of the last address in the parameter list is set to 1; this allows for a variable number of parameters.

(for 24- and 31-bit addressing modes)
The address of the first parameter is placed in register 1.
The address of the subroutine to be called is placed in register 15, with the high order bit on if the subroutine runs in 31-bit mode, and off for 24-bit mode..
A "BALR 14,15" instruction is executed. Note: do not store anything in register 14, as it will be overwritten by this instruction. Note that the BASSM instruction is to be used in the general case.


6. Move command.
First, a matter of terminology: we do not refer to machine instructions as "commands" in assembler. They are "instructions". Each instruction is assigned a mnemonic operation code ("opcode"). There are a number of move instructions, with the following opcodes:

(Note: "Move instruction" usually refers to MVC and/or MVI)

MVI -- "Move Immediate": moves a single-byte value from within the instruction itself to the designated address

MVC -- "Move Characters": moves 1 to 256 characters from one location in main storage (operand2, the source) to another (operand1, the target)

Things to be aware of:
  • (a) the target operand comes first, so read MVC to yourself as "Move characters INTO operand1 FROM operand2"
    (b) the length of operand2 is ignored; the number of characters moved is set by the length operand, or the length of the operand1 if the length operand is omitted
    (c) you cannot move zero (0) bytes, it is alway one or more, because the length operand is stored internally as one less than the number of bytes to be moved (e.g. an internal length of 0 moves 1 byte, an internal length of 1 moves 2 bytes, and an internal length of 255 moves 256 bytes)
    (d) Rule (c) becomes important if you use the EX (Execute) command with MVC to implement variable-length strings.
Other MOVE instructions:
  • MVCL -- "Move Characters Long" -- uses pairs of registers to specify the length and starting address of the source (operand2) and target (operand1) fields

    MVCIN -- "Move Characters Inverse": moves the characters of the source field (operand1) to the target field (operand2) in reverse order (last becomes first)

    MVO -- "Move with Offset" -- sets the leading 4 bits of operand2 (the target field) to zeroes and moves the nibbles (half-bytes) of operand1 (the source field) to operand2 starting at the low-order nibble of the first position

    MVST -- "Move String": moves a character-delimited string from source location to target location

    MVN -- "Move Numerics": moves the low-order 4 bits of each character in operand1 to the corresponding position in operand2

    MVZ -- "Move Zones": moves the high-order 4 bits of each character in operand1 to the corresponding position in operand2

BobC
Member
Posts: 3
Joined: Thu Aug 20, 2015 1:40 am
Location: California, USA

Post by BobC » Thu Aug 20, 2015 5:28 am

Anuj Dhawan wrote:nareshv_99 - What's the benefit of posting in a thread which is around more than 3 years old?
I found this thread; you found this thread; the information we leave behind will benefit those who find it in the future (Google brought me here, it will doubtless do so for many others with a similar query)

BobC
Member
Posts: 3
Joined: Thu Aug 20, 2015 1:40 am
Location: California, USA

Post by BobC » Thu Aug 20, 2015 6:07 am

nareshv_99 wrote:adding a few.. i had been asked to answer below ques..

1. how to move more than 256 chars to a filed ?
2.
var1 dc cl5'abcde'
var2 dc cl5'12345abcde'
write a instruction so that comparison between var1 and var2 should be true

3.
var1 dc cl5'abcde'
var2 dc cl5'12345abcde'
MVC var2,var2
what var2 will have ?
4.
var1 ds cl5'abcde'
can i define the var1 with the above instruction

other than this they asked me how TR instruction works and difference between TR and TRT

please add if anyone had faced any Assembler interview ques
Thanks!
1. how to move more than 256 chars to a filed [sic]?
Possible solutions:
  • (a) code multiple MVC instructions (good for lengths between 257 and maybe 2000 or so)

    (b) code a loop to run the MVC instruction multiple times. For example, you can move 20,000 bytes with a loop that executes a MVC of 250 bytes 80 times

    (c) Use the MVCL instruction (best solution for non-terminated strings, both fixed- and variable-length)

    (d) Use the MVST instruction (best solution for character-terminated variable length strings)

2.

Code: Select all

var1 dc cl5'abcde' 
var2 dc cl5'12345abcde' 
write a instruction so that comparison between var1 and var2 should be true

The following compares the 5 characters in VAR1 agaijnst the last 5 characters in VAR2 (note that offsets begin at 0, so the first character of VAR2 is at offset 0, and the fifth character, where we want to start, is at offset 4):

Code: Select all

  CLC  VAR1,VAR2+4
The code above works because the assembler uses the declared length of VAR1. If were reverse the parameters, we must explicitly code the length:

Code: Select all

  CLC VAR2+4(5),VAR1

3.

Code: Select all

var1 dc cl5'abcde' 
var2 dc cl5'12345abcde' 
MVC var2,var2 
what var2 will have ?

This is perhaps intended as a trick question. Moving a field to itself will not change its value.


4.

Code: Select all

var1 ds cl5'abcde' 
can i define the var1 with the above instruction

Sort of. When you use THE "DS" assembler instruction, the initial value is not stored (it is used by the assembler to infer length, though). If you want the storage allocated for VAR1 to have an initial value, use the "DC" assembler instruction instead of "DS"

[5] other than this they asked me how TR instruction works and difference between TR and TRT

The TR (Translate) machine instruction replaces each byte in the first operand location with a byte obtained from a 256-byte table pointed to by the second operand. The numeric value of the byte from the first operand location is added to the second operand address (as an offset) to select the byte from the table which will replace the first operand byte being examined. The first operand is examined from left to right for the length given (1 to 256 bytes).

TRT (Translate and Test) works in a similar manner, except that instead of replacing the bytes of the first operand, the value obtained from the table is used to determine the next action of the instruction:
(a) if the byte is zero: when this is not the last byte, the instruction proceeds to the next byte; for the last byte, condition code 0 (all function bytes zero) is set and the instruction completes; general registers 1 and 2 remain unchanged
(b) if the byte is non-zero, the address of the source byte is placed in R1 and the value of the table byte is placed in the low-order 8 bits of R2 (the other bits are not changed): when this is NOT the last byte, condition code 1 is set (scan not completed); for the last byte condition code 2 is set (non-zero byte found at end of scan).

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others