Advertisement

CS401 - Computer Architecture and Assembly Language Programming FAQ's 1

Question:WHAT IS MACHINE LANGUAGE?
Answer:Although programmers tend to use C or C++ or Pascal these days, the language closest to the PC hardware is machine language. Not one second during a PCS powered on lifetime passes where the computer is not executing machine language.

Question:WHEN TO USE ASSEMBLY LANGUAGE
Answer:I personally think that except as a learning exercise it is a waste of time writing something in ASM that can be written acceptably fast in a high-level language. Assembly language fits for the following: * Low level control. When you need to change the flags, or the control registers of the processor, as when entering protected mode. * Speed. Programs written in machine language execute fast! It can execute 10-100 times the speed of BASIC, and about twice as fast as a program written in C or Pascal. * Time Critical Code. Critical sections of programs written in higher level languages can be written in assembly to speed up sections. * Small program size. When you write a TSR for example this is very useful. Writing interrupt handlers is where assembly language shines. Assembly language is very flexible and powerful; anything that the hardware of the computer is capable of doing can be done in assembly.

Question:What are interrupts?
Answer:The hardware and software designed for original PC communicated with the CPU by means of a hierarchical and predetermined set of signals called interrupts. When a device or a program needed some action on the part of the CPU it would signal this by sending an interrupt signal. The CPU would sort out the priority of the incoming interrupt requests, with lower number interrupts being handled first (it is common for the CPU to be handling several interrupts concurrently) and then locate the code associated with the interrupt (the Interrupt Request Handler) by examining the Interrupt Vector Table. Each interrupt (starting with interrupt 00H) is allocated four bytes in the vector table. These four bytes serve as an address pointer to the actual software routine associated with the interrupt. These routines may be stored in the ROM BIOS or more commonly in system RAM (where copies of ROM BIOS routines are often uploaded to provide faster access). The interrupt vector table is first initialized by the Start-up ROM but changes are made to it's contents as first the ROM Extensions and later the operating system files are loaded. The ability to update the contents of the interrupt vector table provides a means to easily expand operating system services by making a standard interrupt point to a new Interrupt Handler.

Question:What are registers?
Answer:One of a small number of high-speed memory locations in a computer's CPU. Registers differ from ordinary random access memory in several respects: There are only a small number of registers (the "register set"), typically 32 in a modern processor though some, e.g. SPARC, have as many as 144. A register may be directly addressed with a few bits. In contrast, there are usually millions of words of main memory (RAM), requiring at least twenty bits to specify a memory location. Main memory locations are often specified indirectly, using an {indirect addressing} mode where the actual memory address is held in a register. Registers are fast; typically, two registers can be read and a third written -- all in a single cycle. Memory is slower; a single access can require several cycles.

Question:What is control bus and what function it performs?
Answer:The physical connections that carry control information between the CPU and other devices within the computer. Whereas the data bus carries actual data that is being processed, the control bus carries signals that report the status of various devices. For example, one line of the bus is used to indicate whether the CPU is currently reading from or writing to main memory.
Question:What do you mean by Peripherl devices?
Answer:Peripherals Any piece of hardware connected to a computer; any part of the computer outside the CPU and working memory; Any input or output device connected to a computer. Some examples of peripherals are keyboards, mice, monitors, printers, scanners, disk and tape drives, microphones, speakers, joysticks, plotters, and cameras.

Question:What is difference b/w physical and logical address?
Answer:The segment, offset pair is called a logical address, while the 20bit address is a physical address which is the real thing. Logical addressing is a mechanism to access the physical memory. However I recommend you to read topic 1.8 Segmented memory Model in handouts to get you understand well.

Question:What is difference between DATA LABEL and CODE LABEL?
Answer:Data Label is the label that we use to define data as we defined memory locations num1,num2 ....etc in our programs. Code Label is the label that we have on code as we see in case of conditional jump (Label l1) and is normally used for loop control statements.

Question:What is Segment Wrap Around?
Answer:

Dear Student

For the whole megabyte we need 20 bits while CS and IP are both 16bit registers. We need a mechanism to make a 20bit number out of the two 16bit numbers. Consider that the segment value is stored as a 20 bit number with the lower four bits zero and the offset value is stored as another 20 bit number with the upper four bits zeroed. The two are added to produce a 20bit absolute address. A carry if generated is dropped without being stored anywhere and the phenomenon is called address wraparound.


Question:What is BIOS and how it can be updated?
Answer:

Dear Student

One of the most common uses of Flash memory is for the basic input/output system of your computer, commonly known as the BIOS (pronounced "bye-ose"). On virtually every computer available, the BIOS makes sure all the other chips, hard drives, ports and CPU function together.

What BIOS Does?

The BIOS software has a number of different roles, but its most important role is to load the operating system. When you turn on your computer and the microprocessor tries to execute its first instruction, it has to get that instruction from somewhere. It cannot get it from the operating system because the operating system is located on a hard disk, and the microprocessor cannot get to it without some instructions that tell it how. The BIOS provides those instructions. Some of the other common tasks that the BIOS performs include:
A power-on self-test (POST) for all of the different hardware components in the system to make sure everything is working properly

Activating other BIOS chips on different cards installed in the computer - For example, SCSI and graphics cards often have their own BIOS chips.

Providing a set of low-level routines that the operating system uses to interface to different hardware devices - It is these routines that give the BIOS its name. They manage things like the keyboard, the screen, and the serial and parallel ports, especially when the computer is booting.

Managing a collection of settings for the hard disks, clock, etc.
The BIOS is special software that interfaces the major hardware components of your computer with the operating system. It is usually stored on a Flash memory chip on the motherboard, but sometimes the chip is another type of ROM.

When you turn on your computer, the BIOS does several things. This is its usual sequence:

  1. Check the CMOS Setup for custom settings
  2. Load the interrupt handlers and device drivers
  3. Initialize registers and power management
  4. Perform the power-on self-test (POST)
  5. Display system settings
  6. Determine which devices are bootable
  7. Initiate the bootstrap sequence

Updating BIOS

Occasionally, a computer will need to have its BIOS updated. This is especially true of older machines. As new devices and standards arise, the BIOS needs to change in order to understand the new hardware. Since the BIOS is stored in some form of ROM, changing it is a bit harder than upgrading most other types of software.
To change the BIOS itself, you'll probably need a special program from the computer or BIOS manufacturer. Look at the BIOS revision and date information displayed on system startup or check with your computer manufacturer to find out what type of BIOS you have. Then go to the BIOS manufacturer's Web site to see if an upgrade is available. Download the upgrade and the utility program needed to install it. Sometimes the utility and update are combined in a single file to download. Copy the program, along with the BIOS update, onto a floppy disk. Restart your computer with the floppy disk in the drive, and the program erases the old BIOS and writes the new one. You can find a BIOS Wizard that will check your BIOS at BIOS Upgrades.




Question: What is Interrupt vector Table?
Answer:
Dear Student

The correlation process from the interrupt number to the interrupt handler uses a table called interrupt vector table. Its location is fixed to physical memory address zero. Each entry of the table is four bytes long containing the segment and offset of the interrupt routine for the corresponding interrupt number. The first two bytes in the entry contain the offset and the next two bytes contain the segment. The little endian rule of putting the more significant part (segment) at a higher address is seen here as well. Mathematically offset of the interrupt n will be at nx4 while the segment will be at nx4+2. One entry in this table is called a vector. If the vector is changed for interrupt 0 then INT 0 will take execution to the new handler whose address is now placed at those four bytes. INT 1 vector occupies location 4, 5, 6, and 7 and similarly vector for INT 2 occupies locations 8, 9, 10, and 11. As the table is located in RAM it can be changed anytime. Immediately after changing it the interrupt mapping is changed and now the interrupt will result in execution of the new routine. This indirection gives the mechanism extreme flexibility.

Question: What are the terms ASCII CODE and SCAN CODE?
Answer:
Dear Student

Scan Code

Each key on the keyboard is assigned a unique number called a Scan Code; When a key is pressed, the keyboard circuit sends the corresponding scan code to the computer. Scan code table is given on MDB of Lecture#24.

ASCII Code

I/O devices such as the video monitor and printer are character oriented, and programs such as word processors deal with characters exclusively. Like all data, characters must be coded in binary in order to be processed by the computer. The most popular encoding scheme for characters is ASCII (American Standard Code for Information Interchange) code.

Question: What is Virtual Machine?
Answer:
Dear Student

Virtual machine is a term used by Sun Microsystems, developers of the Java programming language and runtime environment, to describe software that acts as an interface between compiler Java binary code and the microprocessor (or "hardware platform") that actually performs the program's instructions. Once a Java virtual machine has been provided for a platform, any Java program (which, after compilation, is called bytecode) can run on that platform. Java was designed to allow application programs to be built that could be run on any platform without having to be rewritten or recompiled by the programmer for each separate platform. Java's virtual machine makes this possible.
The Java virtual machine specification defines an abstract rather than a real "machine" (or processor) and specifies an instruction set, a set of registers, a stack, a "garbage heap," and a method area. The real implementation of this abstract or logically defined processor can be in other code that is recognized by the real processor or be built into the microchip processor itself.

The output of "compiling" a Java source program (a set of Java language statements) is called bytecode. A Java virtual machine can either interpret the bytecode one instruction at a time (mapping it to a real microprocessor instruction) or the bytecode can be compiled further for the real microprocessor using what is called a just-in-time compiler.

Question: What are Registers and why these are needed?
Answer: Registers are like a scratch pad ram inside the processor and their operation is very much like normal memory cells. They have precise locations and remember what is placed inside them. They are used when we need more than one data element inside the processor at one time.
Question: What is Big-Endian and Little-Endian?
Answer:
Big-endian and little-endian are terms that describe the order in which a sequence of bytes are stored in computer memory. Big-endian is an order in which the "big end" (most significant value in the sequence) is stored first (at the lowest storage address). Little-endian is an order in which the "little end" (least significant value in the sequence) is stored first. For example, in a big-endian computer, the two bytes required for the hexadecimal number 4F52 would be stored as 4F52 in storage (if 4F is stored at storage address 1000, for example, 52 will be at address 1001). In a little-endian system, it would be stored as 524F (52 at address 1000, 4F at 1001).

IBM's 370 computers, most RISC-based computers, and Motorola microprocessors use the big-endian approach.On the other hand, Intel processors (CPUs) and DEC Alphas and at least some programs that run on them are little-endian.
Question:How we calculate Physical Address?
Answer:

for the whole megabyte we need 20 bits while CS and IP are both 16bit registers. We need a mechanism to make a 20bit number out of the two 16bit numbers. Consider that the segment value is stored as a 20 bit number with the lower four bits zero and the offset value is stored as another 20 bit number with the upper four bits zeroed. The two are added to produce a 20bit absolute address. A carry if generated is dropped without being stored anywhere and the phenomenon is called address wraparound. The process is explained with the help of the following diagram.

Therefore memory is determined by a segment-offset pair and not alone by any one register which will be an ambiguous reference. Every offset register is assigned a default segment register to resolve such ambiguity. For example the program we wrote when loaded into memory had a value of 0100 in IP register and some value say 1DDD in the CS register. Making both 20 bit numbers, the segment base is 1DDD0 and the offset is 00100 and adding them we get the physical memory address of 1DED0 where the opcode B80500 is placed.


Question:What is a Stack?
Answer:

Stack is a data structure that behaves in a first in last out manner. It can contain many elements and there is only one way in and out of the container. When an element is inserted it sits on top of all other elements and when an element is removed the one sitting at top of all others is removed first. To visualize the structure consider a test tube and put some balls in it. The second ball will come above the first and the third will come above the second. When a ball is taken out only the one at the top can be removed. The operation of placing an element on top of the stack is called pushing the element and the operation of removing an element from the top of the stack is called popping the element. The last thing pushed is popped out first; the last in first out behavior.


0 Responses