Thursday, 20 April 2017

Positive Body Language - Quick Guide

Body language is defined as the non-verbal communication between two individuals or a group of individuals through physical behaviors such as limb movements, facial expressions, eye movements, other bodily gestures and postures.

Today, the term has assumed so much importance and prominence in all spheres of life that without a positive body language, none of us can survive in the professional arena, personal lives, and in the world, in general.

Body language comes into picture not only during normal conversations, but also during formal discussions, interviews, group discussions, panel meetings, etc. Proper body language not only conveys the right message to the recipient, but also attracts or repels the recipient.

For example, you are facing a job interview and the interviewer is questioning you. Now, although you are polite and replying well to the questions, the interviewer may still not select you. The reason is very simple. Perhaps your body posture or body movements were not appropriate or were rude. This may have led the interviewer to think that you are either not interested, or you are not a good candidate for the job profile.

However, body language is different from sign languages. In sign language, words or information is conveyed voluntarily using hand and finger movements. In sign language, mostly lip movements, finger movements, palm movements and eye movements are used to convey information to the recipient of the information. However, body language is different from sign language in the fact that body language is largely involuntary and is not actively controlled by the mind. However, sign languages are voluntary and are controlled by the mind to convey information.

What is Body Language?

Following are the important features of body language −

It is a set of involuntary actions of the body parts.

It involves movement, especially of the limbs and the head.

It does not have grammar.

It has to be interpreted broadly by other people.

What is Sign Language?

Following are the important features of sign language −

It is not the deliberate movement of body parts to convey information. It is hence, not a voluntary action of body parts.

It has its own grammar.

It has absolute meaning, instead of subjective meaning.

However, this does not mean that if body language is involuntary, it cannot be controlled. By practicing certain techniques mentioned in this tutorial and through careful evaluation of one’s body movements each time, one can improve one’s body language easily.

Body language is quite particular to a specific culture. What is accepted in one culture may be a big ‘No’ in other cultures. Hence, body language is not universal and can be ambiguous too. This tutorial will teach you the essentials of good body language.

What is a Positive Body Language?

People find positive language appealing, receptive and easy to confront. A positive body language must place us in a position of comfort, dignity, and likeability. It helps us to be open to other people and be approachable, helping them feel comfortable when they are interacting with us. If our body movements somehow convey the opposite, then our body language is not positive and hence, needs to be improved.

Body language must not be defensive. Defensive body language discourages people from approaching us and establishing a connect with us.

Body language must not display a sense of disinterest towards the other person, as it can lead to failure in jobs, interviews and high-profile meetings.

The body language of a person must neither be authoritative nor submissive, but assertive to put forth our opinion and stance confidently without meaning any offence to the other person.

Positive body language helps people to be liked by other people in an organization or community and is therefore must for people across disciplines and ethnicities, as it plays a pivotal role in shaping our discussions and relationships with other people in our daily life.

Positive Body Language - Importance

Body language is of utmost importance in this highly competitive world. The corporate sector values good body language a lot and any sign of bad body language can break deals, even leading to loss of network for people.

An old adage says “Actions speak louder than words". Our body posture, along with its movements and placement of different body parts, play an important role in letting out our feelings and emotions, even if we don’t display the emotions voluntarily.

Assertive Behavior

A positive body language helps the person to be more assertive and assists in putting his or her opinion forward more easily than the others. Positive body language is liked by other people and hence, the person carrying a positive body language gets more attention and favor in any discussion.

Non-verbal Communication

Research says that our communication consists of 35% verbal communication and 65% non-verbal communication. This implies that whatever we speak voluntarily comprises of just 35% of what the other person makes out of us. The remaining 65% information about us is learnt from our body language. Our body language helps others identify our emotions, status and even our lifestyle.

Non-verbal communication plays a significant role in conjunction with the spoken words. Our non-verbal communication can reiterate our message, contradict our words, reinforce our statement, substitute the meaning of our sentences and complement the meaning of our words. Since non-verbal communication can either emphasize our point or contradict it, it is necessary to keep our body language in sync with our emotions. Any sign of conflict between the body language and our words can make us appear untrustworthy and deceptive.

Workplace Success

Positive body language is a must in workplaces and corporate environment. Healthy body language can help foster team spirit in the workplace, which can also boost the morale of the employees. Delegation of responsibilities becomes easier through positive body language. It can also help in conveying respect for colleagues and resolving conflicts in the organization.

During corporate meetings, one can display interest, reception, and joy using positive body language. A gentle smile, open palms, leaning forward and eye contact can go a long way in establishing rapport with another person in the meeting thus helping build and sustain a healthy relationship with the other parties in a meeting.

Relationships

Negative body language can give way to a lot of misinterpretation and misunderstandings. Maintaining a body posture and absurd body movements that is offensive to the other person can ruin a relationship.

For instance, you need to understand the emotions and mood of the other person and need to customize your behavior accordingly. If your spouse is in a good mood, then it is okay to laugh or tease her occasionally. However, the same activity can be misinterpreted as sarcasm or irritable behavior if the spouse is not in a good mood. This can lead to issues between couples and can also lead to damaged relationships.

Public Speaking

In public speaking, body language assumes an altogether different importance. If the speaker has a defensive body language or has a passive body language, there are high chances that he or she won’t be listened to intently by the audience. The impact factor of such speeches also is reduced by a large fraction as the audience gets 35% of the entire communication but misses the remaining 65%. Hence, it’s highly important to have proper body movements and posture while speaking on stage in front of an audience.

Body language is very important in all forms of communication. It helps to break the barrier of unfamiliarity and helps to form a better connect with the recipient of information.

Good Standing Postures

Most of the times when we meet people, we are standing in front of them. Be it a casual meeting on the roadside or meeting someone in the office or having a conversation with a friend at a party, many of the conversations in our life happens in a standing position.

Following are the important postures to look for while standing and having a conversation.

Rule 1: Stand Erect

The first point to be kept in mind is to stand with the spine erect. The back must be straight as this gives an impression of being tall. A taller appearance creates good impression as well. You must not slouch or hunch.

Hunching or slouching gives an impression of laziness and lethargy. A person won’t like to approach you to talk if you appear to be weak or lethargic. Active personality is always preferred by people. Bad standing posture also symbolizes low self-esteem. This is not a good attribute to sport while standing.

Rule 2: Face the Person

The second point to remember is to not face sideways from your listener. Try to stand facing the person who you are communicating with. Standing sideways shows that you want to run away from the person and don’t want to continue talking. Watch out for the same signals from the other person as well. If that person is standing sideways, please stop the conversation as soon as possible. This is because the other person is not interested in the conversation.

The best way to stand is to direct your heart towards the other person. Ensure that your heart faces the heart of the other person without any obstruction in between. Standing with arms crossed over the chest is also a big ‘No’. It is better to stand akimbo or with your hands over your waist. Having crossed arms symbolizes defensive position or introvert nature. This type of attitude is seldom liked by people and it puts most of the people off.

Rule 3: Free Your Hands

The third point to be careful about is to not put your hands inside your pockets, while talking to someone. This posture shows disrespect. Keeping hands in the pocket shows that a person is not interested to talk. Remember that arms are the vocal chords of body language and can speak volumes about your attitude and interest.

Rule 4: Look into the Eyes

The fourth point to be careful about is to look into the eyes of the other person without intimidating him or her. If you keep looking away from the other person, it will show lack of interest in the conversation on your part. Keep looking for these signs in the other person too. Perhaps, the other person is looking away from you for most of the time. That will mean that the person is not engrossed in you and hence, it is better to let the person go.

Rule 5: Move, Yet Mind Your Limbs

Last but not the least; it is okay to have some limb movements. Moving hands to a certain extent shows your interest in the conversation and your excitement levels too. Don’t fret too much with hands, and try to keep your palms open. You should also stand with your legs apart. Don’t fiddle with your nose using your fingers because that symbolizes shyness and lack of confidence. Moreover, the legs must not be crossed. Crossed legs signify uncertainty and closed nature.

Good Sitting Postures

A lot of conversations happen while sitting as well. Job interviews, group discussions, or even candid talk with friends happen a lot while sitting in a restaurant, café or library. A lot of attention needs to be given to body language while having a conversation in the sitting position.

Rule 1: Face the Person

Always face towards the other person while speaking. Like in standing posture, here too, try to face your heart towards the heart of the other person. Don’t sit sideways unless necessary.

Also keep looking out for such signs in the other person. If the other person is sitting sideways for some considerable amount of time, it is better to drop out of the conversation as the other person is not interested.

Rule 2: Look into the Eyes

The second point is to maintain direct eye contact with the other person. Look into the eyes of the other person without intimidating him or her.

Rule 3: Mind Your Legs

The third point to focus on is the movement of legs. Since legs are far away from our eyes, we usually forget to keep the legs in check. Too much leg movement is not a good sign. Juggling of the legs show lack of interest in the ongoing activity and a longing to escape from it.

Rule 4: Don’t Slouch

The fourth point to take care of is to not hunch or slouch while sitting. During a job interview, don’t place your arms over the desk and don’t lean forward. The feet must be placed firm on the ground and must not be juggling at all. The spine must be straight and head must be held high. However, when you are having a candid conversation with friends, it is fine to place your arms over the desk and to lean forward. That shows your interest in what the other person is saying.

While sitting, avoid massaging your head, ears or forehead. Doing so signifies vulnerability and uneasiness.

Rule 5: Scream of Importance

While sitting during any conversation, don’t restrict your legs to a small space. Try to spread out your legs a little. It shows that you occupy some space and that you are in charge.

During group discussions, it is a bad gesture for a man to keep one’s legs crossed. However, ladies can sit with legs crossed without any issue. During interviews, it is preferred to sit with uncrossed legs as it signifies openness and acceptance.

The Proper Handshake

Handshakes are an indispensable part of our lives. Day in and day out, we meet friends and colleagues with whom we are supposed to shake hands. Handshakes are as old as the human civilization. In Roman times, the practice of lower arm grasp was followed as a way to check if the other person has concealed a dagger under the sleeves. Slowly, this converted to a form of common greeting and then, it eventually turned into the modern day handshake.

Shaking hands has a lot of Do’s and Don’ts. You should not always offer a handshake to a stranger. Handshake is a sign of welcoming people. If you are unsure whether you are welcome at one place or not, it is better to not go for a handshake. Salespeople can be observed taking care of this all the while they meet a new person. They resort to a simple head-nod rather than initiating a handshake. A handshake should not convey dominance or submission. What it should actually show is equality. Let’s take a quick look at some of the common handshake customs around the world and their features.

The Equality Handshake

Whenever you shake hands, it’s interpreted as a subtle symbolic power struggle between you and the other person. In short, the palm of either of those involved in the handshake must neither be facing down nor facing up.

For a proper handshake, the palms of both the individuals must be in vertical position. Then, both the people must apply the same pressure. If you find that the pressure you are applying is greater or lesser than the other person, then you need to modulate your pressure accordingly.

The Submissive Handshake

The submissive handshake happens when your palm in facing up and is below the palm of the other person. This is called “palm up thrust”. This makes you look submissive. Don’t let the other person get an upper hand at the handshake.

The Dominant Handshake

The opposite of submissive handshake is the dominant handshake. This happens when you place your arm above the palm of the other person and hence, your palm is facing down. This is called “palm down thrust”. This handshake conveys authority and dominance on your part. Don’t let the world think that you are submissive just because your palms are placed over the palm of the other person.

The Double Handler Handshake

When a person presents you with a palm down thrust, respond with your hand in the palm up position and then apply your second hand to make his palm straight. It is considered to be one of the most powerful handshakes in the world as it symbolizes sincerity and a strong bond between the two people involved in the handshake. This handshake is also called as the politician’s handshake, since politicians use this type of handshake a lot.

The Wet Fish Handshake

This is one of the worst handshakes in the world. In this handshake, the hands are cold and sweaty. This is perceived as a weak handshake and the person giving such a handshake is considered to be of weak character and to be lacking commitment.

The Vice Handshake

The vice handshake is another much loathed handshake around the world. This handshake is done by a palm up thrust and then a stronghold of the other person’s hands followed by vigorous hand movements. The strokes are so hard that it appears the person giving such a handshake is too authoritative and dominant.

The Bone Breaker Handshake

In the bone breaker handshake, the person giving this handshake grips the hand of the other person and grinds it with his hands. This handshake signifies aggressive personality and should not be used at all.

The Fingertip Handshake

One of the most hated types of handshakes is the fingertip handshake. In this type of handshake, the two people merely touch the fingertips of each other and give a very slight stroke or may even miss the stroke. This handshake conveys lack of confidence and lack of self-esteem. This is a handshake observed many a times during job interviews. Even before the interview begins, this type of handshake puts off the interviewer and the interviewee’s impression goes for a toss.

The Straight Finger Handshake

In this type of handshake, the person giving the hand has all his fingers straight. It is a very bad and rude gesture not to clasp the palm of the other person, as it shows lack of interest in the meeting and repulsion towards the other person. Always remember to clasp the hands of the other person during a handshake and give it a proper stroke.

Important Tips

It should be noted that after giving a handshake, one should not hold or touch the arm of the person with the other hand. It is a mark of patronizing, which is not seen in good light by people across the world. Only people who are at a higher authority can do so.

One’s hands should not be sweaty or wet while giving a handshake. It is quite unprofessional and rude to have clammy hands while giving a handshake.

You should stand straight or you can bend a little to show respect while shaking hands. It is always to be noted that the palms and the hands must be vertical while giving the handshake, so as to signify equality.

Proper Hand Movements

Hand movements are quite involuntary in nature. However, they tell us a lot about the other person who is using his or her hands while talking. There are rules for positive body language even in case of movement of hands.

Rule 1: Open Your Palms

The first rule is to have an open palm always. Open palms signify openness and acceptance. Open palms also signify honesty and sincerity. However, there is a way to read the open palms as well. If the palms are open while talking but are faced downwards, it signifies a bit of authoritative attitude of the person. This is visible especially in case of handshakes, as we saw in the previous chapter.

However, if the palms are open and are facing upwards, then it is a non-threatening sign. This person is approachable and can be seen as friendly in nature. The turn of palms, hence, completely alters the way others perceive us.

Rule 2: Uncross the Arms

While speaking, the arms should not be crossed and the hands must not be clasped. Clasped hands show lack of commitment and lack of confidence. Crossed arms show defensive or nervous position. It has also been observed that if a person stands with his arms crossed, then he grasps much less of the conversation as compared to a person with open arms. Moreover, defensive body language also leads to lower retention power.

It is in our common nature to cross our arms so as to feel comfortable. However, studies have shown that such a body language is perceived as negative by people. Moreover, clenched fists are also a big no during conversations. The arms should not go below the waist level and must always be raised above the waist while speaking. The arms can occasionally go down but it should not be so throughout the conversation.

Rule 3: Don’t Grip Your Arms

While speaking to someone, don’t grip your arms by crossing them. It is a sign of insecurity. Always avoid holding your arms together in front of your groin area, as it shows insecurity as well. It is called the Broken Zipper position. This is one posture that shows insecurity and submission at the same time and hence, must be avoided at all costs.

Don’t keep adjusting your cuff links in the public as it again shows you are too much concerned about your insecurities of coming out in public. The ladies must make a note that they should not clutch their handbags close to themselves as they talk as it shows their defensive position and their insecure nature.

Rule 4: Zero Arm Barriers

When you are in a restaurant, don’t clutch your coffee mug close to your chest. There should be no arm barrier when you talking to another person. Keep an open body language and hold the coffee mug at a side.

Rule 5: Parallel Over Perpendicular

In group discussions, it is a mandate that if you have to point towards someone, don’t use the arm that will be perpendicular to them. Use the other arm that can point to them and can be parallel to your chest too. Having the arm perpendicular to your chest to point out to others is generally a rude gesture. Always try to have the arm parallel to the body.

Arms and hands have to be used carefully in conversations. The movement of your arms and hands can make or mar your discussion and can alter the outcomes significantly.

Sunday, 16 April 2017

All Interrupt for Emu8086(Assembly language)

The list of all interrupts that are currently supported by the emulator.
These interrupts should be compatible with IBM PC and all generations of x86,
original Intel 8086 and AMD compatible microprocessors, however Windows XP may
overwrite some of the original interrupts.
Quick reference:
the short list of supported interrupts with descriptions:
INT 10h / AH = 0 - set video mode.
input:
AL = desired video mode.
these video modes are supported:
00h - text mode. 40x25. 16 colors. 8 pages.
03h - text mode. 80x25. 16 colors. 8 pages.
13h - graphical mode. 40x25. 256 colors. 320x200 pixels. 1 page.
example:
mov al, 13h
mov ah, 0
int 10h
INT 10h / AH = 01h - set text-mode cursor shape.
input:
CH = cursor start line (bits 0-4) and options (bits 5-7).
CL = bottom cursor line (bits 0-4).
INT 10h/00h
INT 10h/01h
INT 10h/02h
INT 10h/03h
INT 10h/05h
INT 10h/06h
INT 10h/07h
INT 10h/08h
INT 10h/09h
INT 10h/0Ah
INT 10h/0Ch
INT 10h/0Dh
INT 10h/0Eh
INT 10h/13h
INT 10h/1003h
INT 11h
INT 12h
INT 13h/00h
INT 13h/02h
INT 13h/03h
INT 15h/86h
INT 16h/00h
INT 16h/01h
INT 19h
INT 1Ah/00h
INT 20h
INT 21h
INT 21h/01h
INT 21h/02h
INT 21h/05h
INT 21h/06h
INT 21h/07h
INT 21h/09h
INT 21h/0Ah
INT 21h/0Bh
INT 21h/0Ch
INT 21h/0Eh
INT 21h/19h
INT 21h/25h
INT 21h/2Ah
INT 21h/2Ch
INT 21h/35h
INT 21h/39h
INT 21h/3Ah
INT 21h/3Bh
INT 21h/3Ch
INT 21h/3Dh
INT 21h/3Eh
INT 21h/3Fh
INT 21h/40h
INT 21h/41h
INT 21h/42h
INT 21h/47h
INT 21h/4Ch
INT 21h/56h
INT 33h/0000h
INT 33h/0001h
INT 33h/0002h
INT 33h/0003h

When bit 5 of CH is set to 0, the cursor is visible. when bit 5 is 1, the cursor is not
visible.
; hide blinking text cursor:
mov ch, 32
mov ah, 1
int 10h
; show standard blinking text cursor:
mov ch, 6
mov cl, 7
mov ah, 1
int 10h
; show box-shaped blinking text cursor:
mov ch, 0
mov cl, 7
mov ah, 1
int 10h
; note: some bioses required CL to be >=7,
; otherwise wrong cursor shapes are displayed.
INT 10h / AH = 2 - set cursor position.
input:
DH = row.
DL = column.
BH = page number (0..7).
example:
mov dh, 10
mov dl, 20
mov bh, 0
mov ah, 2
int 10h
INT 10h / AH = 03h - get cursor position and size.
input:
BH = page number.
return:
DH = row.
DL = column.
CH = cursor start line.
CL = cursor bottom line.
INT 10h / AH = 05h - select active video page.
input:
AL = new page number (0..7).
INT 10h / AH = 06h - scroll up window.
INT 10h / AH = 07h - scroll down window.
input:
AL = number of lines by which to scroll (00h = clear entire window).
BH = attribute used to write blank lines at bottom of window.
CH, CL = row, column of window's upper left corner.
DH, DL = row, column of window's lower right corner.
INT 10h / AH = 08h - read character and attribute at cursor position.
input:
BH = page number.
return:
AH = attribute.
AL = character.
INT 10h / AH = 09h - write character and attribute at cursor position.
input:
AL = character to display.
BH = page number.
BL = attribute.
CX = number of times to write character.
INT 10h / AH = 0Ah - write character only at cursor position.
input:
AL = character to display.
BH = page number.
CX = number of times to write character.
INT 10h / AH = 0Ch - change color for a single pixel.
input:
AL = pixel color
CX = column.
DX = row.
example:
mov al, 13h
mov ah, 0
int 10h ; set graphics video mode.
mov al, 1100b
mov cx, 10
mov dx, 20
mov ah, 0ch
int 10h ; set pixel.
INT 10h / AH = 0Dh - get color of a single pixel.
input:
CX = column.
DX = row.
output:
AL = pixel color
INT 10h / AH = 0Eh - teletype output.
input:
AL = character to write.
this functions displays a character on the screen, advancing the cursor and scrolling the screen
as necessary. the printing is always done to current active page.
example:
mov al, 'a'
mov ah, 0eh
int 10h
; note: on specific systems this
; function may not be supported in graphics mode.
INT 10h / AH = 13h - write string.
input:
AL = write mode:
bit 0: update cursor after writing;
bit 1: string contains attributes.
BH = page number.
BL = attribute if string contains only characters (bit 1 of AL is zero).
CX = number of characters in string (attributes are not counted).
DL,DH = column, row at which to start writing.
ES:BP points to string to be printed.
example:
mov al, 1
mov bh, 0
mov bl, 0011_1011b
mov cx, msg1end - offset msg1 ; calculate message size.
mov dl, 10
mov dh, 7
push cs
pop es
mov bp, offset msg1
mov ah, 13h
int 10h
jmp msg1end
msg1 db " hello, world! "
msg1end:

INT 10h / AX = 1003h - toggle intensity/blinking.
input:
BL = write mode:
0: enable intensive colors.
1: enable blinking (not supported by the emulator and windows command
prompt).
BH = 0 (to avoid problems on some adapters).
example:
mov ax, 1003h
mov bx, 0
int 10h

bit color table:
character attribute is 8 bit value, low 4 bits set fore color, high 4 bits set background color.
note: the emulator and windows command line prompt do not support background blinking,
however to make colors look the same in dos and in full screen mode it is required to turn off
the background blinking.
HEX BIN COLOR
0 0000 black
1 0001 blue
2 0010 green
3 0011 cyan
4 0100 red
5 0101 magenta
6 0110 brown
7 0111 light gray
8 1000 dark gray
9 1001 light blue
A 1010 light green
B 1011 light cyan
C 1100 light red
D 1101 light magenta
E 1110 yellow
F 1111 white
note:
; use this code for compatibility with dos/cmd prompt full screen mode:
mov ax, 1003h
mov bx, 0 ; disable blinking.
int 10h

Interrupt Vector Table (IVT)

An "interrupt vector table" (IVT) is a data structure that associates a list of interrupt handlers with a list of interrupt requests in a table of interrupt vectors. An entry in the interrupt vector is the address of the interrupt handler. While the concept is common across processor architectures, each IVT may be implemented in an architecture-specific fashion. For example, a dispatch table is one method of implementing an interrupt vector table.

Background

Most processors have an interrupt vector table, including chips from Intel, AMD, Infineon, Microchip[1] Atmel,[2] Freescale, etc.

Interrupt handlers

Handling methods

An interrupt vector table is used in the three most popular methods of finding the starting address of the interrupt service routine:

"Predefined"

The "predefined" method loads the program counter (PC) directly with the address of some entry inside the interrupt vector table. The jump table itself contains executable code. While in principle an extremely short interrupt handler could be stored entirely inside the interrupt vector table, in practice the code at each and every entry is "JMP address" where the address is the address of the interrupt service routine (ISR) for that interrupt. The Atmel AVR[3] [4] and all 8051 and Microchip microcontrollers[5] use the predefined approach.

"Fetch"

The "fetch" method loads the PC indirectly, using the address of some entry inside the interrupt vector table to pull an address out of that table, and then loading the PC with that address.[5] Each and every entry of the IVT is the address of an interrupt service routine. All Motorola/Freescale microcontrollers use the fetch method.[5]

"Interrupt acknowledge"

The "interrupt acknowledge" method, the external device gives the CPU an interrupt handler number. The interrupt acknowledge method is used by the Intel Pentium and many older microprocessors.[5]

When the CPU is affected by an interrupt, it looks up the interrupt handler in the interrupt vector table, and transfers control to it.

See also

Interrupt Descriptor Table (x86 Architecture implementation)

References

"dsPIC33F Family Reference Manual" section 29.1.1 Interrupt Vector Table"AVR Libc User Manual" section: Introduction to avr-libc's interrupt handlingRoger L. Traylor. "Interrupts: AVR interrupt servicing"Gary Hill. "Atmel AVR Interrupt and Timing Subsystems: ATMEGA328P interrupt vector table"Huang, Han-Wat (2005). Pic Microcontroller: An Introduction to Software and Hardware Interfacing. Cengage Learning. p. 247. ISBN 978-1-4018-3967-3. Retrieved 22 April 2013.

External links

Intel® Architecture Software Developer's Manual, Volume 3: System Programming GuideIntel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A:System Programming Guide, Part 1 (see CHAPTER 6, INTERRUPT AND EXCEPTION HANDLING and CHAPTER 10, ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER)]Motorola M68000 Exception and Vector Table

Read more: Interrupt vector table https://www.revolvy.com/main/index.php?s=Interrupt+vector+table&item_type=topic#ixzz4eTOBwnJk 

Concept of interrupt in Assembly language

What is interrupt? 
An interrupt interrupts the normal program flow, and transfers control from our program to Linux so that it will do a system call. Or in simple words,Interrupt is a mechanism by which a program’s flow control can be altered.You can think of it as like signaling Batman.You need something done, you send the signal, and then he comes to the rescue. You don’t care how he does his work.The most important thing to remember about an interrupt is that it can pause the execution of some program at any point between two instructions when an interrupt occurs.  Therefore, you typically have no guarantee that one instruction always executes immediately after another in the program because an interrupt could occur between the two instructions.If an interrupt occurs in the middle of the execution of some instruction, then the CPU finishes that instruction before transferring control to the appropriate interrupt service routine.

In DOS assembly, most things get done with the DOS services interrupt int 21h, and the BIOS service interrupts like int 10h and int 16h. In Linux, all these functions are handled by the kernel. Everything gets done with "kernel system calls", and you call the kernel with int 80h.

The BIOS library is divided into a bunch of sections called interrupts. Each interrupt handled a different aspect of the computer--keyboard I/O, screen drawing functions, file and disk I/O, and so on. Each interrupt then had a whole bunch of functions, each given a number. They used AH (and if the interrupt had a lot of functions, AX) to determine which function to call. Arguments to the interrupts were passed in registers instead of on the stack to speed things up a bit. 

                                      

            

Let's look at a simple interrupt call:
1. int 16h - BIOS Keyboard interrupt
        ah=0  reads key from keyboard without echo
                returns al=ascii, ah=scan code
        ah=1  finds out if a key was hit
              if no keys were pressed:
                zf set (ie, jz NoKey)
                ax=0
              if a key was pressed:
                zf clear (not set -> jnz KeyReady)
                ah=scan code
                 al=ascii

2.  int 21h - DOS functions
        ah=1  reads key from keyboard with echo
                returns al=ascii
        ah=2  prints a character (dl=ascii)
                returns nothing
        ah=5  prints character to printer (dl=ascii)
                returns nothing
        ah=9  prints a string ending in $ (ds:dx=pointer to string)
                returns nothing
        ah=a  buffered keyboard input (ds:dx=pointer to buffer)
              The buffer is in this form:
                1 byte   The max number of characters to read (including enter)
                1 byte   The number of characters read (it gets filled in)
                n bytes  The buffer (n must be at least 1)
              Enter (ascii 13: carriage return) is also stored.
        ah=4c Exit the program (al=error code)

3. int 10h - BIOS Video interrupt
        ah=0  set video mode (al=3 -> text,al=12h,13h -> vga)
                returns nothing
        ah=2  set cursor position (bh=0, dh=row, dl=column)
              dh and dl are zero-based
                returns nothing
       ah=c  display graphics pixel (al=color, bh=0, cx=column, dx=row)
              cx and dx are zero-based
                returns nothing

4. int 19h - Bootstrap loader: Will reboot your computer to the drive specified in dl.Some computers warm boot, some cold boot, and others do nothing register ah doesn't matter here.



Interrupt Instructions

Call to Interrupt Procedure (int, into)

int 3
int	imm8
into
Operation

interrupt 3 -- trap to debugger

interrupt numbered by immediate byte

interrupt 4 -- if overflow flag is 1

Description

The int instruction generates a software call to an interrupt handler. The imm8 (0 to 255) operand specifies an index number into the IDT (Interrupt Descriptor Table) of the interrupt routine to be called. In Protect Mode, the IDT consists of an array of 8-byte descriptors; the descriptor for the interrupt invoked must indicate an interrupt, trap, or task gate. In Real Address Mode, the IDT is an array of four byte-long pointers. In Protected and Real Address Modes, the base linear address of the IDT is defined by the contents of the IDTR.

The into form of the int instruction implies interrupt 4. The interrupt occurs only if the overflow flag is set.

The first 32 interrupts are reserved for system use. Some of these interrupts are used for internally generated exceptions.

The int imm8 form of the interrupt instruction behaves like a far call except that the flags register is pushed onto the stack before the return address. Interrupt procedures return via the iret instruction, which pops the flags and return address from the stack.

In Real Address Mode, the int imm8 pushes the flags, CS, and the return IP onto the stack, in that order, then jumps to the long pointer indexed by the interrupt number.

Example

Trap to debugger:

int $3

Trap to interrupt 0xff:

int $0xff

Trap to interrupt 4:

into

Interrupt Return (iret)

iret
Operation

return -> routine

Description

In Real Address Mode, iret pops CS, the flags register, and the instruction pointer from the stack and resumes the routine that was interrupted. In Protected Mode, the setting of the nested task flag (NT) determines the action of iret. The IOPL flag register bits are changed when CPL equals 0 and the new flag image is popped from the stack.

iret returns from an interrupt procedure without a task switch if NT equals 0. Returned code must be equally or less privileged than the interrupt routine as indicated CS selector RPL bits popped from the stack. If the returned code is less privileged, iretpops SS and the stack pointer from the stack.

iret reverses the operation of an INT or CALL that caused the task switch if NT equals 1.The task executing iret is updated and saved in its task segment. The code that follows iret is executed if the task is re-entered.


Operation

LDTR -> r/m[16]

Description

The Local Descriptor Table Register (LDTR) is stored by sldt as indicated by the effective address operand. LDTR is stored into the two-byte register or the memory location.

sldt is not used in application programs. It is used only in operating systems.

Example

Store the LDTR in the effective address (addressed by the EBX register plus and offset of 5):

sldt 5(%ebx)

Store Task Register (str)

str	r/m16

Operation

STR -> r/m(16

Description

The contents of the task register is stored by sldtas indicated by the effective address operand. STR is stored into the two-byte register or the memory location.

Example

Store str in the effective address (addressed by the EBX register plus an offset of 5):

str 5(%ebx)

Load Local Descriptor Table Register (lldt)

lldt    	r/m16
Operation

SELECTOR -> LDTR

Description

LDTR is loaded by LLDT. The operand (word) contains a selector to a local GDT (Global Descriptor Table). The descriptor registers are not affected.The task state segment LDT field does not change.

The LDTR is marked invalid if the selector operand is 0. A #GP fault is caused by all descriptor references (except LSL VERR, VERW, or LAR instructions).

LLDT is not used in application programs. It is used in operating systems.

Example

Load the LLDT register from the effective address (addressed by the EBX register plus and offset of 5):

lldt 5(%ebx)

Load Task Register (ltr)

ltr	r/m16
Operation

r/m16 -> Task Register

Description

The task register is loaded by LTR from the source register or memory location specified by the operand. The loaded task state segment is tagged busy. A task switch does not occur.

Example

Load the TASK register from the effective address (addressed by the EBX register plus and offset of 5):

ltr 5(%ebx)

Verify a Segment for Reading or Writing (verr, verw)

verr    	r/m16
verw    	r/m16
Operation

1 -> ZF (if segment can be read or written)

Description

VERR and VERW contains the value of a selector in the two-byte register or memory operand. VERR and VERW determine if the indicated segment can be reached in the current privilege level and whether it is readable (VERR) or writable (VERW). If the segment can be accessed, the zero flag (ZF) is set to 1, otherwise the zero flag is set to 0. For the zero flag to be set these conditions must be met:

  • The selector denotes a descriptor; the selector is "defined".

  • The selector is a code or data segment; not a task statement, LDT or a gate.

  • For VERR, the segment must be readable, for VERW, writable.

  • The descriptor privilege level (DPL) can be any value for VERR. otherwise the DPL must have the same or less privilege as the current level and the DPL of the selector.

Validation is performed as if the segment were loaded into DS, ES, FS, or GS and the indicated write or read performed. The validation results are indicated by the zero flag. The value of the selector cannot result in an exception.

Example

Determine if the segment indicated by the effective address (addressed by the EBX register plus an offset of 5) can be reached in the current privilege level and whether it is readable (VERR):

verr 5(%ebx)

Store Global/Interrupt Descriptor Table Register (sgdt, sidt)

sgdt    	mem48
sidt    	mem48
Operation

DTR -> mem48

Description

The contents of the descriptor table register is copied by sgdt/sidt to the six bytes of memory specified by the operand. The first word at the effective address is assigned the LIMIT field of the register. If the operand-size attribute is 32-bits:

  • The base field of the register is assigned to the next three bytes.

  • The fourth byte is written as zero.

  • The last byte is undefined.

If the operand-size attribute is 16-bits, the 32-bit BASEfield of the register is assigned to the next four bytes.

sgdt/sldt are not used in application programs, they are used in operating systems.

Example

Copy the contents of the Global Descriptor Table Register to the specified memory location:

sgdt 0x55555555

Copy the contents of the Interrupt Descriptor Table Register to the effective address (addressed by the EBX register plus an offset of 5):

sidt 5 (%ebx)

Load Global/Interrupt Descriptor Table (lgdt, lidt)

lgdt    	mem48
lidt    	mem48
Operation

MEM48 -> GDTR MEM48 -> IDTR

Description

The GDTR and IDTR are loaded with a linear base address and limit value from a six-byte operand in memory by the lgdt/lidt instructions. For a 16-bit operand:

  • Load the register with a 16-bit limit and a 24-bit base.

  • The six-byte data operand high-order eight bits are not used.

For a 32-bit operand:

  • Load the register with a 16-bit limit and a 32-bit base.

  • The six-byte data operand high-order eight bits are used as the high-order base address bits.

All 48-bits of the six-byte data operand are always stored into by the sgdt/sidt instructions. For a 16-bit and a 32-bit operand, the upper eight-bits are written with the high-order eight address bits. lgdt or lidt, when used with a 16-bit operand to load the register stored by sgdt or sidt, stores the upper eight-bits as zeros.

lgdt and lidt are not used in application programs; they are used in operation system. lgdtand lidt are the only instructions that load a linear address directly in 80386 Protected Mode.

Example

Load the Global/Interrupt Descriptor Table Register from memory address 0x55555555:

lgdt 0x55555555
lidt 0x55555555

Store Machine Status Word (smsw)

smsw    	r/m16

Operation

MSW -> r/m16

Description

The machine status word is stored by smsw in the two-byte register of memory location pointed to by the effective address operand.

80386 machines should use MOV ..., CR0.

Example

Store the machine status word in the effective address (addressed by the EBX register plus an offset of 5):

smsw 5(%ebx)

Load Machine Status Word (lmsw)

lmsw    	r/m16

Operation

r/m16 -> MSW

Description

The machine status word (part of CR0) is loaded by lmsw from the source operand. lmsw can be used to switch to Protected Mode if followed by an intersegment jump to clear the instruction queue. lmsw cannot switch back to Real Address Mode.

lmsw is not used in application programs. It is used in operating systems.

Example

Load the machine status word from the contents of the effective address (addressed by the EBX register plus an offset of 5):

lmsw 5(%ebx)

Load Access Rights (lar)

lar	r/m32, reg32

Operation

r/m16 (masked by FF00) -> r16

r/m32 (masked by 00FxFF00) -> r32

Description

If the selector is visible at the CPL (modified by the RPL) and is a valid descriptor type, lar stores a form of the second doubleword of the descriptor for the source selector. The designated register is loaded with the double-word (high-order) of the descriptor masked by 00FxFF00, and the zero flag is set to 1. The x in 00Fx ... indicates that these four bits loaded by lar are undefined. The zero flag is cleared if the selector is invisible or of the wrong type.

The 32-bit value is stored in the 32-bit destination register if the 32-bit operand size is specified. If the 16-bit operand size is specified, the lower 16-bits of this value are stored in the 16-bit destination register.

For lar, all data segment descriptors and code are valid.

Example

Load access rights from the contents of the effective address (addressed by the EBX register plus an offset of 5) into the EDX register:

lar 5(%ebx),  %edx

Load Segment Limit (lsl)

lsl	r/m32, reg32
Operation

Selector rm16 (byte) -> r16

Selector rm32 (byte) -> r32

Selector rm16 (page) -> r16

Selector rm32 (page) -> r32

Description

lsl loads a register with a segment limit (unscrambled). The descriptor type must be accepted by lsl, and the source selector must be visible at the CPL weakened by RPL. ZF is then set to 1. Otherwise, ZF is set to 0 and the destination register is unchanged.

The segment limit is loaded as a byte value. A page value limit in the descriptor is translated by lsl to a byte limit before lsl loads it in the destination register (the 20-bit limit from the descriptor is shifted left 12 and OR'd with 00000FFFH).

lsl stores the 32-bit granular limit in the 16-bit destination register.

For lsl, code and data segment descriptors are valid.

Example

Load a segment limit from the contents of the effective address (addressed by the EBX register plus an offset of 5) into the EDX register.

lsl 5(%ebx), %edx

Clear Task-Switched (clts)

clts
Operation

0 -> TS Flag in CR0

Description

The task-switched flag in register CR0 is cleared by clta. The TS Flag is set by the 80386 for each task switch. The TS Flag is used as follows:

  • If the TS Flag is set, each execution of the ESC instruction is trapped.

  • If the TS Flag and the MP Flag are both set, execution of a Wait instruction is trapped.

If a task switch is made after an ESC instruction is started, save the processor extension context before a new ESC instruction can be run. The fault handler resets the TS Flag and saves the context.

clts is not used in application program, it is used in operating systems.

clts can only be executed at privilege level 0.

Example

Clear the TS flag:

clts

Adjust RPL Field of Selector (arpl)

arpl	r16, r/m16

Operation

If RPL 1 < RPL 2, 1 -> ZF

Description

arpl has two operands. The first operand is a 16-bit word register or memory variable that contains the value of a selector. The second operand is a word register. If the RPL field of the second operand is greater than the RPL field of the first operand, ZF is set to 1 and the RPL field of the first operand is increased to match the RPL field of the second operand. Otherwise, no change is made to the first operand and the ZF is set to 0.

arpl is not used in application programs, it is used in operating systems.

arpl guarantees that a selector to a subroutine does not request a privilege greater than allowed. Normally, the second operand of arpl is a register that contains the CS selector value of the caller.