Yellow Highlighted Are The Unsolved Questions and Red Highlighted Are The Ones I Got in My Exam 28-2-2013 From This File
Yellow Highlighted Are The Unsolved Questions and Red Highlighted Are The Ones I Got in My Exam 28-2-2013 From This File
Yellow Highlighted Are The Unsolved Questions and Red Highlighted Are The Ones I Got in My Exam 28-2-2013 From This File
(yellow highlighted are the unsolved questions and red highlighted are the
ones I got in my exam 28-2-2013 from this file)
Ans. The values of the base register, the index register, and the constant offset are all added
together to get the effective address. For example “mov [bx+si+300], ax” moves the word
contents of the AX register to the word in memory starting at offset attained by adding BX, SI,
and 300 in the current data segment. Default segment association is again based on the base
register. It might be used with the array base of a two dimensional array as the constant offset,
one dimension in the base register and the other in the index register. This way all calculation
of location of the desired element has been delegated to the processor.
Q3No Question
For which purpose INT 3 is used and describe the funnctionality of this interrupt.
Ans. INT 3, Debug Interrupt .Apart from single stepping debugger has the breakpoint feature.
INT 3 is used for this feature. INT 3 has a single byte opcode so it can replace any instruction. To
put a breakpoint the instruction is replaced with INT 3 opcode and restored in the INT 3
handler. The INT 3 opcode is placed again by a single step interrupt that is set up for this
purpose after the replaced instruction has been executed.
How data movement instructions writtn by SUN Spark processor? Defend your answer by
providing two exampls.
Ans. The Sun SPARC is a very popular processing belonging to the RISC (reduced instruction
set computer) family of processors. SPARC introduces a concept of register window. SPARC
instructions have two sources and a distinct destination. This allows more flexibility in writing
programs .e.g
Data Movement
LDSB [rn], rn(load signed byte)
LDUW [rn], rn (load unsigned
word)
STH [rn], rn (store half word)
Arithmetic
source1 = rn
source2 = rn or simm13
dest = rn
ADD r2, r3, r4
SUB r2, 4000, r5
SLL, SRA, SRL (shifting)
AND, OR, XOR (logical)
Ans. Registers are more than one in number, so we have to precisely identify or name them.
Some manufacturers number their registers like r0, r1, r2, others name them like A, B, C, D etc.
Naming is useful since the registers are few in number. This is called the nomenclature of the
particular architecture. Still other manufacturers name their registers according to their
function like X stands for an index register. This also informs us that there are special functions
of registers as well, some of which are closely associated to the particular architecture. For
example index registers do not hold data instead they are used to hold the address of data.
Q. Why are device drivers necessary given that BIOS already has code that
communicate with the hardware?
Ans. We will be using BIOS disk services to directly see the data stored in the
directory entries by DOS. For this purpose we will be using the BIOS disk
services.
INT 13 - DISK - RESET DISK SYSTEM
AH = 00h
DL = drive
Return:
CF = error flag
AH = error code
Q No 5 Questions
How many pins are used for serial port communication and which type of communication
occur through serial port?
Ans. Serial port is a way of communication among two devices just like the parallel port. the
bits are sent one by one on the serial port in a specially formatted fashion. The serial port
connection is a 9pin DB-9 connector with pins assigned
Q. At which location Interrupt Gate Discriptor Table located? Describe the structure
of the table.
Handling interrupts in protected mode is different. Instead of the IVT at physical address 0 there
is the IDT (interrupt descriptor table) located at physical address stored in IDTR, a special
purpose register. The IDTR is also a 48bit register similar in structure to the GDTR and loaded
with another special instruction LGDT. The format of the interrupt descriptor is as shown
Below. Table from pg 182
The P and DPL have the same meaning as in data and code descriptors.
The S bit tells that this is a system descriptor while the 1110 following it tells
that it is a 386 interrupt gate.
Q In IAPX88 processor what limitations are there for multiplying a 16-bit number by
2 and which operation can be used to resolve multiplication?
Ans. There are no specific limitations IAPX88 processor only provides us the basic building blocks.
We build a plaza out of these blocks, or a building, or a classic piece of architecture is only dependent
upon our imagination. With our logic we can extend these algorithms as much as we want.
SHL operation can be used to resolve the multiplication.
Ans. Motorolla 68K processors are very similar to Intel x86 series in their architecture and
instruction set. 68K processors have 16 23bit general purpose registers named from A0-A7 and
D0-D7. A0-A7 can hold addresses in indirect memory accesses. These can also be used as
software stack pointers. Stack in 68K is not as rigit a structure as it is in x86. Motrolla processors
allow bit addressing, that is a specific bit in a byte or a bit field, i.e. a number of bits can be
directly accessed. 68K allows indirect memory access using any A register. 68K has no
segmentation; it however has a paged memory model.
Q2. how interrupt pointer register work when call instruction is executed ?
Q3.given instruction is wrong write this in correct format mov DX, 0X123?
Data Movement
LDSB [rn], rn (load signed byte)
LDUW [rn], rn (load unsigned word)
STH [rn], rn (store half word)
Q6. Code of c language is given and asking for write the given code in assembly
language?5mark
Q7.which pin of db 9 connector assign to ring indicator?2 marks
9 pins
A triple fault is a special kind of exception generated by the CPU when an exception occurs while the
CPU is trying to invoke the double fault exception handler, which itself handles exceptions occurring
while trying to invoke a regular exception handler
Q short jump.
Ans. If the offset is stored in a single byte as in 75F2 with the opcode 75 and operand F2, the
jump is called a short jump. F2 is added to IP as a signed byte. If the byte is negative the
complement is negated from IP otherwise the byte is added. Unconditional jumps can be short,
near, and far. The far type is yet to be discussed. Conditional jumps can only be short. A short
jump can go +127 bytes ahead in code and -128 bytes backwards and no more. This is the
limitation of a byte in singed representation.
int 16 services
5 marks questions:
Bios services
BIOS services are very low level. A level further lower is only directly controlling the hardware.
BIOS services provide a hardware independent layer above the hardware and OS services
provide another higher level layer over the BIOS services. The layer of BIOS provides services
like display a character, clear the screen, etc. All these layers are optional in that we can skip to
whatever lower layer we want. BIOS exports its various services through different interrupts.
Keyboard services are exported through INT 16, parallel port services through INT 17 and
similarly others through different interrupts. The BIOS INT 14 provides serial port services. We
will use a mix of BIOS services and direct port access. Important BIOS services regarding the
serial port are discussed below.
INT 14 - SERIAL - INITIALIZE PORT
AH = 00h
AL = port parameters
DX = port number (00h-03h)
Return:
AH = line status
AL = modem status
Q1: Suppose we want to execute multiple process at the same time for this purpose we need
to store and restore states of processing running immediately operating system which
process is used to store and restore states process in a multiple operating system
Q2: which register is used by GDT to store its base and limits
The base and limit of GDT is stored in a 48bit register called the GDTR. This register is loaded with a
special instruction LGDT and is given a memory address from where the 48bits are fetched.
Q3: which interrupt is used to extend read disk and have can we use extended read service
also mention all the attributes which are used in this service
INT 13 - INT 13 Extensions - EXTENDED READ
AH = 42h
DL = drive number
DS:SI -> disk address packet
Return:
CF = error flag
AH = error code
disk address packet's block count field set to number of blocks
successfully transferred
Q4: write an assembly program for drawing a line in graphics mode of video service
Q5: at which locations interrupts gate descriptor table is stored and describe the structure
of the table with an example
Ans. The IDT (interrupt descriptor table) located at physical address stored in IDTR, a special purpose
register. The IDTR is also a 48bit register similar in structure to the GDTR and loaded with another
special instruction LGDT. The format of the interrupt descriptor is as shown below.
Pg 182 table
Q7: In c and Pascal calling conventions which register are used as scratch whenever we call
a functions
In C and Pascal calling conventions, both standards do not preserve or guarantee the value of EAX, ECX,
EDX, FS, GS, EFLAGS, and any other registers.
2 Marks Questions
Role of selector is to select on descriptor from the table of descriptors and the role of descriptor is to define the
actual base address.
3MarksQuestions
Q1 - Information through descriptor's first 16 Bits used to represent what ?
In descriptor table D bit defines that this segment is to execute code is 16bit mode or 32bit mode.
The Global Descriptor Table or GDT is a data structure used by Intel x86-family processors
starting with the 80286 in order to define the characteristics of the various memory areas used
during program execution, including the base address, the size and access privileges like
executability and writability. These memory areas are called segments in Intel terminology.
The GDT can hold things other than segment descriptors as well. Every 8-byte entry in the GDT
is a descriptor, but these can be Task State Segment (or TSS) descriptors, Local Descriptor Table
(LDT) descriptors, or Call Gate descriptors. The last one, Call Gates, are particularly important
for transferring control between x86 privilege levels although this mechanism is not used on
most modern operating systems.
5 Marks Questions
1 - Define Coordination between data bus, control bus and address bus?
The group of bits that the processor uses to inform the memory about which element to read
or write is collectively known as the address bus. Another important bus called the data bus is
used to move the data from the memory to the processor in a read operation and from the
processor to the memory in a write operation. The third group consists of miscellaneous
independent lines used for control purposes. For example, one line of the bus
is used to inform the memory about whether to do the read operation or the write operation.
These lines are collectively known as the control bus. These three buses are the eyes, nose, and
ears of the processor. It uses them in a synchronized manner to perform a meaningful
operation. Although the programmer specifies the meaningful operation, but to fulfill it the
processor needs the collaboration of other units and peripherals. And that collaboration is
made available using the three buses.
2 - Values required for the following registers to write a character on serial port using INT 21?
- AH =
- AL =
- DX =
INT 14 - SERIAL - WRITE CHARACTER TO PORT
AH = 01h
AL = character to write
DX = port number (00h-03h) (04h-43h for Digiboard
pg 128
JNZ instruction is used to determine the zero flag. Jump is taken is zero flag is set
(2) Which memory space is needed to store all the task of the register. 2 marks
PCB
(3) How many types of descriptors also mention their names. 3 marks
IDT can have 3 types of descriptors; interrupt gate, trap gate and task gate
3 types of descriptor tables.
GDT(global), LDT(local), IDT(interrupt)
(4) in read from file int21 service the error flag and file handling goes in which register and flag.
3marks
Bx = file handle
Cf = error flag
(5)Which instruction is used to write disk system and how can we write the system and also write 4
attributes which are use system
(6) how many flags are not ues in arithmetic operation and also write their names.3 marks
AH = 0Ch
BH = page number
AL = pixel color
CX = column
DX = row
Q1: Describe the structure of “Device Driver File” which is used for device
management? 2 Marks
ANS: Device driver file starts with a header containing a link to the next driver in the first four
bytes followed by a device attribute word. The most important bit in the device attribute word is
bit 15 which dictates if it is a character device or a block device. If the bit is zero the device is a
character device and otherwise a block device. Page 158
Q2: Why trap flag has a special relation with interrupt and debugger? 2 Marks
ANS: INT 1 is used in debugging with the trap flag. If the trap flag is set the Single Step
Interrupt is generated after every instruction. So INT 1 relates to trap flag.
Q3: Whether the relation b/w RET and CALL is dependent or independent? 2 Marks
ANS: Both the instructions are commonly used as a pair, however technically they are
independent in their operation. The RET works regardless of the CALL and the CALL works
regardless of the RET. If you CALL a subroutine it will not complain if there is no RET present
and similarly if you RET without being called it won’t complain. Page 56
Q4: Who is responsible for clear the stack in C and Pascal calling conventions? 2 Marks
ANS: In C the caller removes the parameter while in Pascal the callee removes them. Page 179
Q5: What are the important “command code” in request header of device driver? 3Marks
ANS: Important command codes include 0 to initialize, 1 to check media, 2 to build a BIOS
parameter block, 4 and 8 for read and write respectively. Page 158
a) Command to view stack from an offset address 0x20 in “Memory Window 1”?
M1 SS:0020
Q7: Which attribute of INT10 being used for getting information about Super VGA? 3
Marks
AX = 4F00h
Return:
AH = status
Q8: Which pins are used in Serial Port? Which type of communication is in it? 5 Marks
1. Carrier Detect
2. Received Data
3. Transmitted Data
5. Signal Ground
7. Request to send
8. Clear to Send
9. Ring Indicator
Serial port is a way of communication among two devices just like the parallel port. The basic
difference is that whole bytes are sent from one place to another in case of parallel port while the
bits are sent one by one on the serial port in a specially formatted fashion.
Q9: What is the function of “segment override prefix” and what changes it brings to
opcode? 5 Marks
ANS: To override the association for one instruction of one of the registers BX, BP, SI or DI,
we use the segment override prefix. For example “mov ax, [cs:bx]” associates BX with CS for
this one instruction. For the next instruction the default association will come back to act. The
processor places a special byte before the instruction called a prefix. Page 26.
Q10: Draw a half straight line in graphics mode middle of the screen from extreme left to
right? 5 Marks
[org 0x0100]
int 0x21
Q11: Using the function “int multiply (int x, int y)” from C and convert it into assembly
code? 5 Marks
call _ multiply
add esp, 8
Q. Give an example instruction to show based register indirect addressing mode. 2mrks
Ans. A base register is used in brackets and the actual address accessed depends on the
value contained in that register. For example “mov [bx], ax” moves the two byte contents of the
AX register to the address contained in the BX register in the current data segment.
Q. How many broad categories of video services are classified? And also write the
name of these video services.
Ans. The video services are exported via INT 10. We will discuss some very simple services.
Video services are classified into two broad categories;
In graphics mode a location in video memory corresponds to a dot on the screen. In text
mode this relation is not straightforward. The video memory holds the ASCII of the character to
be shown and the actual shape is read from a font definition stored elsewhere in memory.
Q. What is the purpose of bios parameter block?
Ans. The BIOS parameter block is a structure that provides parameters about the storage
medium. It is stored in the first sector or the boot sector of the device.
An 'abort' is caused by an attempt to access a memory or I/O location which is out of bounds to the
program that is currently executing. An abort is signalled by some device external to the ARM asserting a
signal on the CPU's ABORT line.
Q. How to reset disk file system using INT 13 disk rest service? 3mrks
Q. Which two instructions are used to check whether particular bits are set or not? How
these two instructions differ from each other?
Ans. AND can be used to check whether particular bits of a number are set or not. Previously
we used shifting and JC to test bits one by one. Now we introduce another way to test bits,
which is more powerful in the sense that any bit can be tested anytime and not necessarily in
order. AND can be applied on a destination with a 1-bit in the desired position and a source,
which is to be checked. If the destination is zero as a result, which can be checked with a JZ
instruction, the bit at the desired position in the source was clear.
However the AND operation destroys the destination mask, which might be needed later as
well. Therefore Intel provided us with another instruction analogous to CMP, which is non-
destructive subtraction. This is the TEST instruction and is a non-destructive AND operation. It
doesn’t change the destination and only sets the flags according to the AND operation. By
checking the flags, we can see if the desired bit was set or cleared.
Q. What is multithreading?
Ans. Multi-threading is a widespread programming and execution model that allows multiple
threads to exist within the context of a single process. These threads share the process' resources,
but are able to execute independently. The threaded programming model provides developers
with a useful abstraction of concurrent execution.
Q. In assembly language programming which attributes of INT 10 service are being used
for getting information about super VGA.
Ans.
We use service 4F of INT 10 for getting information about super VGA, details of INT-
104F are given below:-
INT 10 - VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION
AX = 4F00h
ES:DI -> buffer for SuperVGA information (see #00077)
Return: AL = 4Fh if function supported
AH = status
00h successful
ES:DI buffer filled
01h failed
Q. In INT 10 of video services while writing graphics pixel, what do the values of registers
BH, AL, CX, and DX corresponds to? 5mrks
Ans.
Q. What is divide overflow error? Complete the following code such that it will cause
divide overflow error. mov BL,________ mov AX,__________ DIV BL
Ans.
Q. What are the content at the starting position of the file designated as device driver?
Ans. Device driver file starts with a header containing a link to the next driver in the first four
bytes followed by a device attribute word. The most important bit in the device attribute word is
bit 15 which dictates if it is a character device or a block device. If the bit is zero the device is a
character device and otherwise a block device. Next word in the header is the offset of a strategy
routine, and then is the offset of the interrupt routine and then in one byte, the number of units
supported is stored. This information is padded with seven zeroes.
Q. In which technique user feels the programs are running at the same time and how
does this technique works?
Ans. Multitasking is the technique in which the user feels the programs are running at the same
time. In multitasking scheduler is responsible to schedule the threads. Time division technique
is used to give each thread limited time to execute, then second thread and so on. Due to fast
processing speed of the processor user feel that multiple programs are running at same time.
Ans. The P bit must be set to signal that this segment is present in memory. The P
and DPL have the same meaning as in data and code descriptors. The S bit tells that
this is a system descriptor while the 1110 following it tells that it is a 386 interrupt gate
MOV AX, 10
MOV AX, 0X10
MOV AX, [0X10]
Ans.
Q. Which processor’s instruction set allows the following instructions and describe what
task will be performed by each of these instructions:
CLR(A3)
EXG D0, D2
Move.B (A1),(A2)
MoveA (2222).L,A4
Q.11: Consider the following pseudo-code and write the assembly code for it. Note: There is
more credit for a shorter code.
cx=1
Ans.
[org 0x0100]
cmp a1, b1
jb exit
cmp b1, c1
jb exit
mov cx, 1
Q.12: Explain the purpose of assembly language instructions from 1 to 4 lines as given
below:
Mov si,12
Mov al,[cs:si]
Mov [opcode],al
Q.1: What are different registers settings for file closing using INT21 service?
Ref: Pg 161
Q.2: Which bit of port 37A enables the IRQ7 triggering by the ACK pin?
Ans. Port 37A is the control port. Our interest is with bit 4 of this port which enables the
IRQ 7 triggering by the ACK pin. We have attached a circuit that connects 8 LEDs with
the parallel port pins.
Q.3: How many types of user descriptors are used in 8088 architecture? Write their names
only.
Ans. In 8088 architecture, user descriptors are not used. The concept of GDT, LDT and
IDT was first introduced in Intel 80386 microprocessor.
Q.4: What is the purpose of direction flag (DF) and what will happen if DF= 1?
Ans. The direction of movement is controlled with the Direction Flag (DF) in the flags
register. If this flag is cleared the direction is from lower addresses towards higher
addresses and if this flag is set the direction is from higher addresses to lower
addresses. If DF is cleared, this is called the auto increment mode of string instruction,
and if DF is set, this is called the auto decrement mode. There are two instructions to
set and clear the direction flag.
Q.5: In case of a typical central processing unit, how program counter governs the
complete execution of an instruction?
Ans. Instructions run one after another, first, second, third and so on. Instructions have
a positional relationship. The whole logic depends on this positioning. If the computer
executes the fifth instructions after the first and not the second, all our logic is gone. The
processor should ensure this ordering of instructions. A special register exists in every
processor called the program counter or the instruction pointer that ensures this
ordering. “The program counter holds the address of the next instruction to be
executed.” A number is placed in the memory cell pointed to by this register and that
number tells the processor which instruction to execute; for example 0xEA, 255, or 152.
For the processor 152 might be the add instruction. Just this one number tells it that it
has to add, where its operands are, and where to store the result. This number is called
the opcode. The instruction pointer moves from one opcode to the next. This is how our
program executes and progresses. One instruction is picked, its operands are read and
the instruction is executed, then the next instruction is picked from the new address in
instruction pointer and so on.
Q.6: Following are three common video services for INT 10 used in text mode. Identify the
use of each video service which is listed below:
AH=00h
AH=01h
AH=02h
Ans.
Some common video modes include 40x25 text mode (mode 0), 80x25 text mode
(mode 2), 80x50 text mode (mode 3), and 320x200 graphics mode (mode D).
INT 10 - VIDEO - SET TEXT-MODE CURSOR SHAPE
AH = 01h
CH = cursor start and options
CL = bottom scan line containing cursor (bits 0-4)
Ans.
(a) 0001
(b) First Physical Address:-
00010 + 00000 = 00010
(c) E000
First Physical Address:-
0E000 + 00000 = 0E000
Q7. What value is needed to be put in the table index in order to access the
GDT
LDT
Ans.
The table index (TI) is set to 0 to access the global table of descriptors called the GDT
(Global Descriptor Table). It is set to 1 to access another table, the local descriptor table
(LDT) that we will not be using
Ans.
The above code writes the $ terminated string pointed by ‘msg’ on the screen, the
details of the interrupt are given below:-
1DDD;0436
1234;7920
74F0;2023
0000:6727
FFFF:4336
Ans.
(a)1DDD: 0436
1DDD0 + 00436
= 1E206
(b)1234: 7920
12340 + 07920
= 19C60
(c) 74F0;2023
= 74F00 + 02023
= 76F23
(d)0000: 6727
= 00000 + 0627
= 00627
(e)FFFF : 4336
= FFFF0 + 04336
= 04326
MCQS
The thread registration code initializes the PCB and adds it to the linked list so that the __________ will
give it a turn. ► assembler ► scheduler (Page 141) ► linker ► debugger
In NASM an imported symbol is declared with the ............................ while and exported symbol is
declared with the............................
► Global directive, External directive
For the execution of the instruction “DIV BL”, the implied dividend will be
stored in ► AX (Page 85) ► BX ► CX ► DX
Question No: 18 ( Marks: 1 ) - Please choose one INT 21 service 01H is used to read character from
standard input with echo. It returns the result in ______ register.
► AL (Page 152) ► BL ► CL ► BH
Question No: 19 ( Marks: 1 ) - Please choose one BIOS sees the disks as
► logical storage
IRQ is referred to