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.
- (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