Free Essay

Information on 8086

In: Science

Submitted By nitishnijhawan
Words 6814
Pages 28
INFORMATION OF 8086 WORKING WITH MS-DOS AND BIOS....

The Processing Environment
The processing environment for MASM includes the processor on which your programs run, the operating system your programs use, and the aspects of the segmented architecture that influence the choice of programming models.

8086-Based Processors
The 8086 “family” of processors uses segments to control data and code. The later 8086-based processors have larger instruction sets and more memory capacity, but they still support the same segmented architecture. Knowing the differences between the various 8086-based processors can help you select the appropriate target processor for your programs.
The instruction set of the 8086 processor is upwardly compatible with its successors. To write code that runs on the widest number of machines, select the 8086 instruction set. By using the instruction set of a more advanced processor, you increase the capabilities and efficiency of your program, but you also reduce the number of systems on which the program can run.

Processor Modes

Real mode allows only one process to run at a time. The mode gets its name from the fact that addresses in real mode always correspond to real locations in memory. The MS-DOS operating system runs in real mode.
Windows 3.1 operates only in protected mode, but runs MS-DOS programs in real mode or in a simulation of real mode called virtual-86 mode. In protected mode, more than one process can be active at any one time. The operating system protects memory belonging to one process from access by another process; hence the name protected mode.
Protected-mode addresses do not correspond directly to physical memory. Under protected-mode operating systems, the processor allocates and manages memory dynamically. Additional privileged instructions initialize protected mode and control multiple processes.

8086 and 8088
The 8086 is faster than the 8088 because of its 16-bit data bus; the 8088 has only an 8-bit data bus. The 16-bit data bus allows you to use EVEN and ALIGN on an 8086 processor to word-align data and thus improve data-handling efficiency. Memory addresses on the 8086 and 8088 refer to actual physical addresses.

80186 and 80188
These two processors are identical to the 8086 and 8088 except that new instructions have been added and several old instructions have been optimized. These processors run significantly faster than the 8086.

80286
The 80286 processor adds some instructions to control protected mode, and it runs faster. It also provides protected mode services, allowing the operating system to run multiple processes at the same time. The 80286 is the minimum for running Windows 3.1 and 16-bit versions of OS/2®.

80386
Unlike its predecessors, the 80386 processor can handle both 16-bit and 32-bit data. It supports the entire instruction set of the 80286, and adds several new instructions as well. Software written for the 80286 runs unchanged on the 80386, but is faster because the chip operates at higher speeds.
The 80386 implements many new hardware-level features, including paged memory, multiple virtual 8086 processes, addressing of up to 4 gigabytes of memory, and specialized debugging registers. Thirty-two–bit operating systems such as Windows NT and OS/2 2.0 can run only on an 80386 or higher processor.

80486
The 80486 processor is an enhanced version of the 80386, with instruction “pipelining” that executes many instructions two to three times faster. The chip incorporates both a math coprocessor and an 8K (kilobyte) memory cache. (The math coprocessor is disabled on a variation of the chip called the 80486SX.) The 80486 includes new instructions and is fully compatible with 80386 software.

8087, 80287, and 80387
These math coprocessors work concurrently with the 8086 family of processors. Performing floating-point calculations with math coprocessors is up to 100 times faster than emulating the calculations with integer instructions. Although there are technical and performance differences among the three coprocessors, the main difference to the applications programmer is that the 80287 and 80387 can operate in protected mode. The 80387 also has several new instructions. The 80486 does not use any of these coprocessors; its floating-point processor is built in and is functionally equivalent to the 80387.

Operating Systems
With MASM, you can create programs that run under MS-DOS, Windows, or Windows NT — or all three, in some cases.

MS-DOS

In real-mode programming, you can access system functions by calling MS-DOS, calling the basic input/output system (BIOS), or directly addressing hardware. Access is through MS-DOS Interrupt 21h.

Windows protected mode allows for much larger data structures than real mode, since addressable memory extends to 16 megabytes. In protected mode, segment registers contain selector values rather than actual segment addresses. These selectors cannot be calculated by the program; they must be obtained by calling the operating system. Programs that attempt to calculate segment values or to address memory directly do not work in protected mode.
Protected mode uses privilege levels to maintain system integrity and security. Programs cannot access data or code that is in a higher privilege level. Some instructions that directly access ports or affect interrupts (such as CLI, STI, IN, and OUT) are available at privilege levels normally used only by systems programmers.
Windows protected mode provides each application with up to 16 megabytes of “virtual memory,” even on computers that have less physical memory. The term virtual memory refers to the operating system’s ability to use a swap area on the hard disk as an extension of real memory. When a Windows application requires more memory than is available, Windows writes sections of occupied memory to the swap area, thus freeing those sections for other use. It then provides the memory to the application that made the memory request. When the owner of the swapped data regains control, Windows restores the data from disk to memory, swapping out other memory if required.

Segmented Architecture
The 8086 family of processors employs a segmented architecture — that is, each address is represented as a segment and an offset. Segmented addresses affect many aspects of assembly-language programming, especially addresses and pointers.
Segmented architecture was originally designed to enable a 16-bit processor to access an address space larger than 64K. (The section “Segmented Addressing,” later in this chapter, explains how the processor uses both the segment and offset to create addresses larger than 64K.) MS-DOS is an example of an operating system that uses segmented architecture on a 16-bit processor.
With the advent of protected-mode processors such as the 80286, segmented architecture gained a second purpose. Segments can separate different blocks of code and data to protect them from undesirable interactions. Windows takes advantage of the protection features of the 16-bit segments on the 80286.
Segmented architecture went through another significant change with the release of 32-bit processors, starting with the 80386. These processors are compatible with the older 16-bit processors, but allow flat model 32-bit offset values up to 4 gigabytes. Offset values of this magnitude remove the memory limitations of segmented architecture. The Windows NT operating system uses 32-bit addressing.

Segment Protection

Segmented architecture is an important part of the Windows memory-protection scheme. In a “multitasking” operating system in which numerous programs can run simultaneously, programs cannot access the code and data of another process without permission.
In MS-DOS, the data and code segments are usually allocated adjacent to each other, as shown in Figure 1.1. In Windows, the data and code segments can be anywhere in memory. The programmer knows nothing about, and has no control over, their location. The operating system can even move the segments to a new memory location or to disk while the program is running.

Figure 1.1 Segment Allocation

Segment protection makes software development easier and more reliable in Windows than in MS-DOS, because Windows immediately detects illegal memory accesses. The operating system intercepts illegal memory accesses, terminates the program, and displays a message. This makes it easier for you to track down and fix the bug.
Because it runs in real mode, MS-DOS contains no mechanism for detecting an improper memory access. A program that overwrites data not belonging to it may continue to run and even terminate correctly. The error may not surface until later, when MS-DOS or another program reads the corrupted memory. Segmented Addressing

Segmented addressing refers to the internal mechanism that combines a segment value and an offset value to form a complete memory address. The two parts of an address are represented as segment:offset
The segment portion always consists of a 16-bit value. The offset mode or a 32-bit value in 32-bit mode.
In real mode, the segment value is a physical address that has an arithmetic relationship to the offset value. The segment and offset together create a 20-bit physical address (explained in the next section). Although 20-bit addresses can access up to 1 megabyte of memory, the BIOS and operating system on International Standard Architecture (IBM PC/AT and compatible) computers use part of this memory, leaving the remainder available for programs. Segment Arithmetic
Manipulating segment and offset addresses directly in real-mode programming is called “segment arithmetic.” Programs that perform segment arithmetic are not portable to protected-mode operating systems, in which addresses do not correspond to a known segment and offset.
To perform segment arithmetic successfully, it helps to understand how the processor combines a 16-bit segment and a 16-bit offset to form a 20-bit linear address. In effect, the segment selects a 64K region of memory, and the offset selects the byte within that region. Here’s how it works: 1. The processor shifts the segment address to the left by four binary places, producing a 20-bit address ending in four zeros. This operation has the effect of multiplying the segment address by 16. 2. The processor adds this 20-bit segment address to the 16-bit offset address. The offset address is not shifted. 3. The processor uses the resulting 20-bit address, called the “physical address,” to access an actual location in the 1-megabyte address space. Figure 1.2 illustrates this process. Figure 1.2 Calculating Physical Addresses

A 20-bit physical address may actually be specified by 4,096 equivalent segment:offset addresses. For example, the addresses 0000:F800, 0F00:0800, and 0F80:0000 all refer to the same physical address 0F800.

Language Components of MASM
Programming with MASM requires that you understand the MASM concepts of reserved words, identifiers, predefined symbols, constants, expressions, operators, data types, registers, and statements.

Reserved Words
A reserved word has a special meaning fixed by the language. You can use it only under certain conditions. Reserved words in MASM include:
• Instructions, which correspond to operations the processor can execute.
• Directives, which give commands to the assembler.
• Attributes, which provide a value for a field, such as segment alignment.
• Operators, which are used in expressions.
• Predefined symbols, which return information to your program.
MASM reserved words are not case sensitive except for predefined symbols (see “Predefined Symbols,” later in this chapter).
The assembler generates an error if you use a reserved word as a variable, code label, or other identifier within your source code.

Identifiers

An identifier is a name that you invent and attach to a definition. Identifiers can be symbols representing variables, constants, procedure names, code labels, segment names, and user-defined data types such as structures, unions, records, and types defined with than 247 characters generate an error.

Certain restrictions limit the names you can use for identifiers. Follow these rules to define a name for an identifier:
• The first character of the identifier can be an alphabetic character (A–Z) or any of these four characters: @ _ $ ?
• The other characters in the identifier can be any of the characters listed above or a decimal digit (0–9).
Avoid starting an identifier with the at sign (@), because MASM 6.1 predefines some special symbols

Defining Basic Attributes with .MODEL
The .MODEL directive defines the attributes that affect the entire module: memory model, default calling and naming conventions, operating system, and stack type. This directive enables use of simplified segments and controls the name of the code segment and the default distance for procedures.
You must place .MODEL in your source file before any other simplified segment directive. The syntax is:
.MODEL memorymodel [[, modeloptions ]]
The memorymodel field is required and must appear immediately after the .MODEL directive. The use of modeloptions, which define the other attributes, is optional. The modeloptions must be separated by commas. You can also use equates passed from the ML command line to define the modeloptions.
The following list summarizes the memorymodel field and the modeloptions fields, which specify language and stack distance:

Small, Medium, Compact, Large, and Huge Models
The traditional memory models recognized by many languages are small, medium, compact, large, and huge. Small model supports one data segment and one code segment. All data and code are near by default. Large model supports multiple code and multiple data segments. All data and code are far by default. Medium and compact models are in-between. Medium model supports multiple code and single data segments; compact model supports multiple data segments and a single code segment.
Huge model implies individual data items larger than a single segment, but the implementation of huge data items must be coded by the programmer. Since the assembler provides no direct support for this feature, huge model is essentially the same as large model.

Tiny Model
Tiny-model programs run only under MS-DOS. Tiny model places all data and code in a single segment. Therefore, the total program file size can occupy no more than 64K. The default is near for code and static data items; you cannot override this default. However, you can allocate far data dynamically at run time using MS-DOS memory allocation services.
Tiny model produces MS-DOS .COM files. Specifying argument to the linker. Therefore, the /AT argument is not necessary with /AT does not insert a .MODEL directive. It only verifies that there are no base or pointer fixups, and sends /TINY to the linker.

Creating a Stack

The stack is the section of memory used for pushing or popping registers and storing the return address when a subroutine is called. The stack often holds temporary and local variables.
If your main module is written in a high-level language, that language handles the details of creating a stack. Use the .STACK directive only when you write a main module in assembly language.
The .STACK directive creates a stack segment. By default, the assembler allocates 1K of memory for the stack. This size is sufficient for most small programs.
To create a stack of a size other than the default size, give .STACK a single numeric argument indicating stack size in bytes:
.STACK 2048 ; Use 2K stack

.MODEL ;Sets Memory Model Directive .MODEL name [,language] .MODEL TPASCAL (TASM Only) You use this directive to set the memory model in a program. Memory models set the size limits of the code and data areas for your program. They determine whether the assembler considers data or code references as NEAR or FAR addresses. You must use the .MODEL directive before using the simplified segment directives such as .CODE or .DATA. For the 80386: if you want to use 16-bit segments, use the .386 directive after .MODEL. Otherwise, the assembler defaults to 32-bit segments. The memory model name can be TINY (TASM only), SMALL, MEDIUM, COMPACT, LARGE, or HUGE. Here is a list of memory models and their definitions: Model Means ----- -------------------------------------------------------- TINY Code and Data fit into 64K. The program can be made into a .COM file. This model, also called Small Impure, is available only in Turbo C. SMALL All data fits in one 64K segment, all code fits in one 64K segment. Maximum program size is 128K. MEDIUM All data fits in one 64K segment, but code may be greater than 64K. COMPACT Data may be greater than 64K (but no single array may be), code must be less than 64K. (Turbo: static data must be less than 64K.) LARGE Both data and code may be greater than 64K, but no single array may be. (Turbo: static data must be less than 64K.) HUGE Data, Code, and and data arrays may be greater than 64K. Here is a summary: Model DATA vs. 64K CODE vs. 64K Arrays vs. 64K ----- ------------ ------------ -------------- TINY < < < (TASM only) SMALL < < < MEDIUM < > < COMPACT > < < LARGE > > < HUGE > > > If you want to link your program into a high level language, you should use the same memory model as it does, and specify the name of that language (BASIC, C, PASCAL, or FORTRAN) when you use .MODEL.

HOW TO USE THE DEBUGGER

CONTENTS * Introduction * Pre-Debugger: Syntax Errors * The Debugger * How to Debug * Mechanics of Using TD * Some Pulldown Menus * Breakpoints * CPU Window * Clipboard Facilities * Bottom of page

Introduction
Here is basic information for using a debugger. We will be using the Turbo Debugger. Since this is a fairly complex piece of software, we will help you with some orientation information below. Actually, there are 3 versions of the Turbo Debugger:
TD, TDW and TD32.
(You can find them under the TASM folder.) TD is for 16-bit DOS applications while TDW and TD32 are for 16-bit and 32-bit windows applications. For this course, you only need to use TD. This is what we assume here. But TD only works from a DOS environment. That means that you need to invoke TD from within an MS-DOS PROMPT window (see FAQs for this).
Note that MS-DOS provides an extremely simple debugger called DEBUG. You might find it useful to learn this simple debugger as well (the information on this is in chapter 5 and Appendix E of your text).
Pre-Debugger: Syntax Errors
Before we even approach the debugger, let us address a class of errors for which it is an overkill to use the debugger: that is when you do not even succeed in assembling your program! No object file could be produced. These are basically syntax errors.
The fix here is basically trivial. First note that if you invoke ``tasm hw1'', it will report the line numbers of each instruction that has a syntax error. All you need to do is to address the problems, one offending line at a time! HINT: To ask tasm to print out the actual offending instructions, not just their line numbers, do this instead: :> tasm /z hw1 |
The Debugger
Where does the debugger come in? Well, to debug errors that has to do with the logic of your program. These are sometimes called semantic errors as opposed to the ``syntax errors'' in the previous paragraph. Of course, you can still avoid using a debugger for small programs. When your programs become complex the debugger may be essential.
The first thing to realize is that in order to use the debugger, your assembler and linker needs to store certain additional information needed by the debugger. E.g., if you define the variable Greeting db 'Hello, World!' | then your .obj and .exe files needs to retain the symbolic information telling the debugger that data at offset ABCD0123h (or whatever) is the same as "Greeting". As the human user, you prefer to see the symbolic name "Greeting" rather than "ABCD0123h". To do this, such ``symbolic information'' that are normally discarded by TASM needs to be recorded in the object file it produces. This can be done by calling TASM and TLINK with the options /zi and /v (respectively). Here is a slight revision of the ``First Steps'' instructions used in the TASM notes: :> tasm /zi /z hw1 :> tlink /v hw1 :> td hw1 |
Note that the resulting .obj and .exe files with these options are bigger than they otherwise would be. To see other command options available with tasm or tlink, you can invoke "tasm" or "tlink" without any arguments.
How to Debug
There are 4 basic steps: 1. Discovering the Bug. Is there one? It is not always obvious that you have a bug. (WHY?) 2. Isolating the Bug. Where is it? Locate the part(s) of the code that is causing the bug. 3. Finding the Bug. What exactly is wrong with the buggy code fragment? 4. Fixing the Bug. How should the buggy fragment be rewritten?
The debugger gives you tools to help in all these steps. E.g., you can run the code in a step-by-step fashion or until some breakpoint you set in the code. In between these execution steps, you can examine memory and CPU state (variables, registers, flags and stack).
Mechanics of Using TD
NOTE: It is best to print a copy of this and read it while seated in front of the Turbo Debugger (say, with your hw1 program loaded, using the method suggested above).
Overview The Main TD window shows a standard (pull-down) menu bar at the top. The menu bar lists the following menus: File, Edit, View, Run, Breakpoints, Data, Options, Windows, Help. The status bar at the bottom of the TD window contains helpful information about the current context. For instance, you often see a list of all the functions associated with the function keys F1 to F10. For instance, F9 is the ``Run'' command. That means these functions are available in the current context.
TD Windows Within the Main TD window we can have a variety of (sub)windows. At any moment, several of these windows may be active. Each active windows is numbered (1,2,3, etc.) and this number is displayed on the upper right hand corner of window. Below, we will go into some of these windows and discuss how to manage them. Among the active windows, one of them is the current top window. The top window has a little green rectangle at its upper left corner. You can close this window by clicking on this little green rectangle.
Exercise 1 The function key F6 (called ``Next'') steps through your active windows, allowing each of them to be ``top window'' in turn. Try stepping through your windows: how many windows do you have at this point? What is the current number of active windows? How is the ``top window'' indicated?
Online Help We already mentioned the Help (pulldown) menu. But there are more ``immediate'' or context-sensitive help available: 1. Status Bar We noted that status bar usually shows the list of functions associated with the 10 function keys. But if you hold down the ALT key, the status bar will show the functions associated with ALT+Function Keys.
[E.g., ALT+F5 is the ``User'' Function. Try this! This just gets you back to the MS-DOS Prompt Window. This is useful if you need to see any output from your executed code. To get back from the MS-DOS Prompt, type any key. ]
If you hold down the CTRL key, you will see the CTRL+key functions.
[E.g., CTRL+I allows you to inspect the variable that the cursor is currently pointed at.] 2. Function F1 This key opens a help window containing information about the current top window, with further subtopics to choose from. 3. SpeedMenu This can be invoked with the right mouse click at any time. In most windows, you will get a list of options suitable for that window.
Some Pulldown Menus
Let us go over some of the pulldown menus:
VIEW pulldown menu
The types of windows available are listed under the VIEW menu. We describe three of them here: 1. Module Window This is usually the first window you see, and is number 1. It shows your source code, and so may appear the most familiar to you (after all, you wrote that code!). 2. Watch Window This is usually the second window you see, and thus is number 2. You can set up variables and expressions in this window to ``watch'' (their values change as your program is executed). In fact, exercise 1, you probably saw the Module and Watch Windows (the watch window is quite narrow, and you may miss it). 3. CPU Window This window is most useful for assembly language programming (i.e., for this course!) as it shows the state of your CPU. At the top bar of this window, it will tell you the CPU class (486, Pentium, etc) of the current machine. This window is partitioned into 5 smaller display regions called panes: * Code pane: this pane on the top left is the largest, showing the machine code and disassembled assembly instructions of your executable program. (Source code lines can also be displayed.) * Registers pane: this pane is to the right of the code pane. * Flags pane: this pane is to the right of the registers pane, showing the 8 CPU flag bits. * Dump pane: This is directly below the code pane, showing the hex dump of any memory area accessible by your program. * Stack pane: this is on the bottom right, showing the contents of the program stack (in hex)
For more details, see CPU Window below.
Exercise 2 Write a simple program with these instructions (in addition to the usual stuff): mov ax,0ffffh mov bx,8000h neg bx add ax,bx |
Now load the program into TD, and call up the CPU Window (in addition to the default Module and Watches Windows). Now step through the execution of the program using F7. After each step, describe the contents of ax and bx, and the status flag variables.
WINDOW pulldown menu
This menu helps you manage the various windows. This menu is divided into two halves (separated by a horizontal line): the top half contains commands such as Zoom (=F5), Next (=F6), Next pane (=tab), etc. The bottom half is a list of the currently active windows.
RUN pulldown menu
Windows are for watching. But for action, you need to execute your code. For this, the RUN menu provides several modes of execution: 1. Run (=F9), i.e., until program terminates (or until the next breakpoint). This is the simplest mode. 2. Trace into (=F7 or ALT+F7), i.e., single stepping, instruction by instruction. What constitutes a single step depends on which the current ``top window''. If the top window is the Module window or if you use F7, then a single line of source code is executed. If the top window is the CPU window or if you use ALT+F7, then a single machine instruction is executed. If the current source line contains a function call, TD traces into the function (assuming it was compiled with debug information). Some machine instructions, however, cause multiple instructions to be executed include: CALL, INT, LOOP, etc. 3. Step over (=F8) This is like ``Trace into'' except that when the instruction pointer is at a function call, then the entire function is executed and you are next placed at the statement following the function call. 4. Animate (similar to run until terminate, except it pauses between machine instructions to allow you to catch what is happening) 5. Restart (move the instruction pointer back to the first instruction)
Exercise 3 List the functions available as a CTRL+key functions. List the functions in the SpeedMenu under the Code Pane of the CPU window.
For each of these functions, briefly describe what they do (you can either experiment and/or read up the online help), and describe a debugging situation in which you might find them useful.
Breakpoints
Breakpoints are a device to cause the computer to take specific actions at specific points in its execution. The user can define a breakpoint by specifying three pieces of information. 1. The location where the breakpoint is set. 2. The condition which allows the breakpoint to activate. 3. The action that takes place when the breakpoint is activated.
The simplest kind of breakpoint is one that (a) is associated with a specific instruction in the program, which (b) is always activated (condition is ``always true'') and (c) pauses the program execution (action is ``break''). These are called simple breakpoints. It is the default assumed by TD, and it should suffice for our purposes. Using this, you run the program at full speed until specific instructions, at which points you can examine the state of the memory and CPU.
As an example of more complex breakpoints, you could have a global breakpoint which (a)' is evaluated after each line of source code, which (b)' is activated when a particular variable is modified and (c)' logs the value of an expression.
How do you set simple breakpoints? Well, you only need to specify an instruction in the program. The simplest is to do this from within the Module Window, or from the Code Pane in the CPU Window: * First place the cursor at an executable line of code where a breakpoint is desired. (How do you tell if a line is executable?) You then left-click the 2 leftmost columns of line. Instead of left-click, you can also use function F2 (see the status line). NOTE: if the line already has a breakpoint, then this action removes that breakpoint. Hence this is also called the toggle action. * If you use the Breakpoint->At menu option, you can also place a simple breakpoint at the current cursor position. However, since this has a pop-up Breakpoint option dialog box, you could also specify more complex types of breakpoint.
Breakpoint addresses must be entered when you use the keyboard to enter breakpoints. (You can see this in the Breakpoint option dialog box above.) Here are the kinds of addresses you can specify: * #<number> -- for instance, #68 specifies a breakpoint in line 68 of your source code.
NOTE: If you have several program modules, you need to preface the line number with the module name. E.g. #hw1#68 refers to line 68 in hw1.asm module. * Symbolic names -- for instance, labels can be specified. If you have have a label called ``repeat'', you can use this as an address.
How do you see all the current breakpoints? In the Breakpoints Window, which can be activated using the View->Breakpoints menu option. This window has two panes: the left pane lists all the current breakpoints, the right pane gives details about the breakpoint that is currently highlighted. The SpeedMenu from the left pane has options to add or delete breakpoints, etc.
Exercise 4 Write a simple program using the LOOPE command to read 20 input characters and to store them in a variable called INPUTS. Note that LOOPE is discussed in the exercises of Chapter 6. However, you may break out of the loop early, when a carriage return (CR) is entered. After the last input character, store a '$' character (this is the 21st character if all twenty characters are read, otherwise, the '$' is stored instead of the CR. Use TD to examine the status flags in this loop.
CPU Window
Above we briefly introduced the CPU window. You can activate any pane of the CPU window by left-clicking the pane. The SpeedMenu the activated pane is then available. We now describe two of the panes in more detail.
(1) CODE PANE: There are three display modes in the code pane. In the SpeedMenu for the Code Pane, the command ``Mixed'' accepts three options: ``No'', ``Yes'' and ``Both''. The verbose mode is ``Yes'', and shows for each source code line: * the source code line, * the machine instruction(s), * and the disassembled code in the same line
Note that a source code can generate several machine instructions. For instance, the usual preliminary lines mov ax,@data mov ds,ax | in the procedure main of a program called hw1.asm produces the following information in the code pane: ... #hw1#main: mov ax,@data cs:0000 B8B20A mov ax,0AB2 #hw1#31: mov ds,ax cs:0003 8ED8 mov ds,ax ... |
Note that the first mov instruction produces 3 bytes of machine instructions (B8B20A), the second mov instruction produces only two bytes (8ED8). The offsets of these two instruction in the code segment (cs register) are 0000 and 0003, respectively.
Navigating the code pane. The SpeedMenu in Code Pane has some useful tools for navigating your code: * Origin: positions you at the location of the instruction pointer. * Follow: goes to the destination address of current highlighted instruction. Useful only if the current instruction is a CALL, INT, JMP, JZ, etc. * Previous: restores the code pane to the previous position.
Another useful SpeedMenu command is called Assemble. It allows you to replace the current line of instruction with any other (single) instruction that you specify.
(2) DUMP PANE: This is a hex display of an area in memory. The leftmost path of each line shows the starting address of the line (e.g., ds:0000). In the default display format (byte format), you see 8 bytes per line, and to the right of these 8 bytes are their representation in the IBM extended character set (which is an extension of the ASCII set). You can use the GOTO command in the SpeedMenu to examine variables (e.g., GOTO Input, assuming you have defined the variable "Input"). NOTE: There is also a Dump Window which can be invoked from the View Menu. This gives the same information as the Dump Pane, except that it now can be resized. TRY THIS!
Clipboard Facilities
In debugging, we often have to copy hex addresses or transfer chunks of hex information. Humans tend to make mistakes with such data. TD has extensive copy and paste facilities to and from the Clipboard to help in this process. Hence it is worth your while to learn some tricks for using the Clipboard.
E.g., if a dialog box pops up and asks you for some information (e.g., the address of a breakpoint), it is sometimes possible to paste this information from the clipboard.
The first thing to realize is that information on the clipboard are ``objects'', not just inert data. For instance, if you copy a chunk of the memory to the clipboard, the address of that chunk is remembered. When the contents of these memory locations change, your clipboard contents changes! Hence, each item in the clipboard has an associated type, such as: * address: an address, with no associated data * CPU code: address and byte list of data in memory from the DUMP window * Expression: from the Watches Window * String: a text string
Furthermore, when we paste an item from the clipboard, there are three options: to paste it as a string (if the item is a string), as a location (if item has an address) or as contents (for an address item). Here is how you perform basic clipboard operations: * Copying to Clipboard: position the cursor on the item (or highlight it with the INSERT and arrow keys), then press SHIFT+F3. * Pasting from Clipboard: press SHIFT+F4 (or use the Clip button in some dialog box) to bring up the Clipboard's Pick dialog box. * Viewing the Clipboard contents: choose View->Clipboard menu option.
HOW HOW TO USE TURBO DEBUGGER!!!!Turbo Debugger
Keywords: Assembly language, Turbo Debugger
If you are going to build assembly programs, it might be usefull to actually see that how this works. To achieve this, we are going to use the Turbo Debugger that comes with Borland C compiler. In this tutorial we are going to write a short program using mov instructions. Once we have the .EXE file, we are going to use Turbo Debugger to run this program step by step and see how it works. To make me life easy I wrote a template program, so that I can add the instructions I need to this template. Below, you can see it

IDEAL

MODEL small
STACK 266

;---- Insert INCLUDE "filename" directives here

;---- Insert EQU and = equates here

DATASEG

;---- If an appropriate error occurs and the program should halt, store an appropriate
; error code in exCode and execute a JMP Exit instruction. To do this from a
; submodule, declare the Exit label in an EXTRN directive.

exCode DB 0

;---- Declare other variables with DB, DW, etc, here

speed DB 100 ;one byte variable

;---- Specify an EXTRN variables here

CODESEG

;---- Specify an EXTRN procedure here

Start: mov ax,@data ;initialize DS to address mov ds,ax ;of data segment mov es,ax ; make es=ds

;---- Insert program subroutines calls, etc. here

Exit: mov ah,04Ch ;DOS function: Exit program mov al,[exCode] ;Return the exit code value int 21h ;call DOS. Terminate program

END Start ;End program

Basically, the program loads 10 (Ah), 20 (14h), 30 (1Eh) and 40 (28h) into ax, bx, cx and dx. mov ax,10 mov bx,20 mov cx,30 mov dx,40

Then, the value of speed is loaded into ah and the offest of the "speed" is loaded into si.

mov ah,[speed] ;load the value of speed into ah mov si,offset speed ;load address of speed into al

Save the program as move.asm; assembly and link it program using tasm and tlink. Once you have the .EXE file open a DOS prompt window. Change the directory for C:\Borlandc\Bin. Type then td
The Turbo Debugger application window looks like below

Click on OK. Enlarge the window as much as you can. Using the Open submenu (from File menu) open the move.exe. The program might give you an error message "Program has no symbol table" . Do not worry about that.

Click on OK. Click on the program's window corner and extend it. Now, you can clearly see that there are several "regions". in the biggest region you can see the program. the first one is the program region

In this region you can see the program you wrote. If you pay attention to the above picture you can see move ax,000A, which load in the ax register the value 10 (10 = Ah). The next line will load 20 (14h) in the bx register and so on.

The second region is the register's region.

Here, you can see the each register value. You can see that, for example, the content of ax register is now 0000h.

The third region is the flag's region.

Here, you can see the each flag value.

The fourth region is the flag's region.

Here, you can see some memory locations.

The last region is the stack region.

Here, you can the stack values.

Now, you want to see you program working step by step. To do this, press F8. Once you did that, the prompter goes down one step.

As the first line there is move ax,5108 now, you might see that the content of ax become 5108. In the secod line you move the content of ax into ds. So after executing this line, the content of ds will be 5108 as well.

After executing the third line, the content of es will also become 5108. Press once again F8.

Now, if you press f8 again, you have to see that the content of ax will become 10 (Ah). Before pressing F8 look on the content of ax (which is now 5108).

Now, you will see the value of bx register changing. Now, it is 0000h and it suppose to become 14h (which corresponds to 20).

Now, you will see the value of cx register changing. Now, it is 0000h and it suppose to become 1Eh (which corresponds to 30).

Now, you will see the value of dx register changing. Now, it is 0000h and it suppose to become 28h (which corresponds to 40).

The next register content that will change is ah (the high level byte of it). This will became 64h (corresponding to 99 which is the value of the "speed"). As 99 is lower then 255, this value can be represented using 8 bits. After this step tha value of ax will be 640Ah (al remains unchanged).

The next register content that will change is si. This register will become 0001.

The next step will load 4Ch into the register ah. The content of ax will then became 4C0Ah.

The nest step will make the content of al 0000h. The content of ax will became 4C00h.

And, finally, the last step where the program will call int21 and return to DOS.

The program will let you konw the exit code (if you take a look on the program listing) you defined exCode DB 0. This is the exit code you see now.

You can download the move program from here…...

Similar Documents

Premium Essay

Information

...response to these stimuli. Through the perceptual process, we gain information about properties and elements of the environment that are critical to our survival.  A number of factors operate to shape and sometimes distort perception These factors can reside:  i) In the perceiver  ii) In the Object or target being perceived or  iii) In the context of the situation in which the perception is made.  1. Characteristics of the Perceiver: Several characteristics of the perceiver can affect perception. When an individual looks at a target and attempts to interpret what he or she stands for, that interpretation is heavily influenced by personal characteristics of the individual perceiver. The major characteristics of the perceiver influencing perception are:  a) Attitudes: The perciver's attitudes affect perception. For example, Mr. X is interviewing candidates for a very important position in his organization - a position that requires negotiating contracts with suppliers, most of whom are male. Mr. X may feel that women are not capable of holding their own in tough negotiations. This attitude with doubtless affect his perceptions of the female candidates he interviews.  b) Moods: Moods can have a strong influence on the way we perceive someone. We think differently when we are happy than we do when we are depressed. In addition, we remember information that is consistent with our mood state better than information that is inconsistent with our mood state. When in a positive......

Words: 1629 - Pages: 7

Premium Essay

Information

...describe the advantage of using the relational model. (6). Create an E-R diagram using graphical depicting software that could theoretically be used in a restaurant application. Now that you know the purpose of this assignment, I will define three key terms that will be discussed in this assignment. The first term is Database (DB), which is a collection of information organized in such a way that a computer program can quickly select desired pieces of data. You can think of a database as an electronic filing system. Traditional databases are organized by fields, records, and files. To access information from a database, you need a database management system (DBMS). This is a collection of programs that enables you to enter, organize, and select data in a database. The second term, Entity-Relationship Model (ER) is a way of graphically representing the logical relationships of entities or objects in order to create a database. The ER model was first proposed by Peter Pin-Shan Chen of Massachusetts Institute of Technology (MIT) in the 1970s (Ricardo, 2012, p. 19). The third term is relational model, which views information in a database as a collection of distinctly named tables. Each table has a specified set of named columns, each column name or attribute being distinct within a particular table, but not necessarily between tables. Next, I will address the advantages of a relational model specific to ACME Global Consulting. Since Acme Global Consulting is a leader in......

Words: 1493 - Pages: 6

Premium Essay

Information

... Information is power; there is no doubt about this. There is universal agreement that information is important and it cannot be underestimated. I therefore would like to classify information as the fifth factor of production. Increasing the information input factor mix definitely improves productivity. The need for adequate, timely and up to date information in taking both personal and corporate decisions has often been stressed. One of the means through which information is transmitted is the newspaper, which is hereby referred to as newspaper information. Daily newspapers are accorded a great deal of importance in most companies and ZRA inclusive. In most cases, the source of most policy changes, priority changes and even interest changes has been the information read on the pages of newspapers. Newspaper information has thus become an integral part of today`s information sources. But the major thrust of Newspaper information today has been in the area of investigative, educational, occupational, social and business information. Newspapers have also been an intrinsic element in waging social revolution or campaigning for change in social structure. One basic strength of newspapers compared to other media is accessibility of information, whereas a basic weakness of television and radio is a lack on an adequate information supply system that could provide news and other information desired the time frame of broadcasting hours. One of the great impediments to success in......

Words: 371 - Pages: 2

Premium Essay

Information

...There are Information Systems and Applications use by different parts of an organization. The ones that will be discussed in this essay are: Accounting, Finance, and Human Resource Department. The different systems that interchange within the organization’s departments are: Management Information System, Enterprise Resource Planning System, and the Expert System. Each of these systems help management had access to important information that help make changes on the organization’s productivities and uses the information to make changes within the organization and all business decisions. For example, the production plans and production results are inputs to the budgeting and accounting system (for financial planning) and the human resources systems (for staffing, training, etc.). The systems use a blend of computer and communications, hardware and software, human-machine interaction, and internal and external sources of data. A management information system (MIS) is a system or process that provides the information necessary to manage an organization effectively. MIS is viewed and used at many levels by management. It should be supportive of an organization’s longer term strategic goals and objectives. It is also those everyday financial accounting systems that are used to ensure basic control is maintained over financial recordkeeping activities. Financial accounting systems are an important functional element or part of the total MIS structure. An Enterprise Resource......

Words: 447 - Pages: 2

Premium Essay

It Information

...Penetration testing is a method of evaluating computer and network security by simulating a security attack or breach. This can be an internal or external test or both. I would assume penetration testing is a good method of finding potential threats so it should be part of a security risk assessment or at least be a test after security measures have been put in place. There are multiple types of assessments in security risk management. Asset identification is key, as are assessing threats and vulnerabilities. Once those factors have been identified impact and likelihood assessments are necessary. Finally value must be considered for every counter measure put in place or proposed to be put in place Gibson, D. (2010). Managing Risk in Information Systems. Sudbury, MA. Jones & Bartlett Learning. ISBN-13: 978-0-7637-9187-2 ISBN-10: 0763791873...

Words: 288 - Pages: 2

Free Essay

It Information

...critical condition, so it has major IT infrastructure problems. CEO of PH Max Berndt is trying to find the right solution. He has an option to go with monolithic system that will provide consistency across PH’s facilities but may not give doctors enough flexibility or he can choose service-oriented architecture (SOA), a modular design that will allow PH to standardize incrementally and selectively but poses certain risks as a newer technology. Evaluating pros and cons of both SOA and monolithic system, SOA seems less expensive in the long run than the monolithic system. CEO Max Berndt does not like the basic force to make homogeneous across the network hospitals, especially for non-routine stuff. So, he considers applying SOA as a new information system. Monte Ford, Sr. VP/CIO of American Airlines, recommends SOA and mentioned as “the company doesn’t have the luxury of waiting for a lot more certainty; its infrastructure needs a solutions now”. Likewise Randy Heffner, a VP at Forrester Research also recommends SOA. The interesting thing to note is that none of the experts recommend a monolithic system on case commentary. It is recommended PH to apply SOA because of low costs, easy to use, flexible and low time consuming...

Words: 267 - Pages: 2

Premium Essay

Information

...businesses to offer clients more than just standard advertising. The 4As originally coined the term the "new advertising, " however this title did not appropriately incorporate many other aspects included in the term "IMC" - most notably, those beyond traditional advertising process aside from simply advertising.[8] Overall, an influx of new marketplace trends in the late 20th century spurred organizations to shift from the standard advertising approach to the IMC approach: * Decreasing message impact and credibility: The growing number of commercial messaging made it increasingly more difficult for a single message to have a noteworthy effect. * Decreasing costs of databases: The cost of storing and retrieving names, addresses and information from databases significantly declined. This decline allowed marketers to reach consumers more effectively. * Increasing client expertise: Clients of marketing and public relations firms became more educated regarding advertising policies, procedures and tactics. Clients began to realize that television advertising was not the only way to reach consumers. * Increasing mergers and acquisitions of agencies: Many top public relations firms and advertising agencies became partners or partnered with other communication firms. These mergers allowed for more creativity, and the expansion of communication from only advertising, to other disciplines such as event planning and promotion. * Increasing global marketing: There was a......

Words: 1164 - Pages: 5

Premium Essay

Information

...Learning Outcomes Week 2 INFORMATION SYSTEMS IN BUSINESS 1. Describe the information age and differences among data, information, business intelligence and knowledge. Information age: Infinite numbers of facts are widely available to anyone who can use a computer. Data: raw facts that describe the characteristics of an event or object. Information: data converted into a meaningful and useful context. Business intelligence: information collected from multiple source, such as suppliers, customers, competitors, partners and industries, that analyses patterns, trends and relationships for strategic decision making. Knowledge: include the skills, experience and expertise, coupled with information and intelligence that creates a person’s intellectual resources. 2. Identify the different departments in a company and why they must work together to achieve success. Common functional area in an organisation: Accounting: provides quantitative information about the finances of the business, include recording, measuring and describing financial information. Finance:Deals with the strategic financial issues associated with increasing the value of the business, while observing applicable laws and social responsibilities. Human resource: includes the policies, plans and procedures for the effective management of employees. Sales: is the function of selling a good or service and focuses on increasing customer sales, which increases company revenues. Marketing: is......

Words: 792 - Pages: 4

Free Essay

Information

...Information Assurance and Security Nick Rosasco Karthikreddy Nalapatla 3884252 What is a Port Number A port number is a way to identify a specific process to which an internet or other network message is to be forwarded when it arrives at a server. For the transmission control protocol and the user Datagram protocol, a port number is a 16 bit integer that is put the header appended to a message unit. This port number is passed logically between the client and the server transport layers and physically between the transport layer and the Internet Protocol layer and it will forward it on to the other layers. For an example, a request from a client to a server on the internet may request a file to transfer from the host File Transport Protocol (FTP) server. In order to pass that request which is passed by us to the FTP in the remote server, the Transmission Control Protocol (TCP) identifies the port number which is of 16 bit length, then that port will forward the request to the FTP Server. FTP and the FTP Port Number The File Transfer Protocol (FTP) is a standard network protocol used to transfer computer files from one host to the other host over a TCP – based network, for an example Internet. FTP is a Client – server architecture and uses a separate control and the data connections between the client and the server. The model of the FTP is shown below. Fig 1: File Transport Protocol Model Executing......

Words: 1400 - Pages: 6

Free Essay

Information

...It is a market where all important information is available to all people involved at the same time and where the price responds immediately to the available information. | The primary markets deal with the trading of newly issued securities. The corporations, governments and companies issue securities like stocks and bonds when they need to raise capital. The investors can purchase the stocks or bonds issued by the companies. The secondary market is that part of the capital market that deals with the securities that are already issued in the primary market. The investors who purchase the newly issued securities in the primary market sell them in the secondary market. The secondary market needs to be transparent and highly liquid in nature as it deals with the already issued securities. In the secondary market, the value of a particular stock also varies from that of the face value. The resale value of the securities in the secondary market is dependent on the fluctuating interest rates. | Higher risk is associated with greater probability of higher return and lower risk with a greater probability of smaller return. This trade off which an investor faces between risk and return while considering investment decisions is called the risk return trade off. | Conflicts of interest and moral hazard issues that arise when a principal hires an agent to perform specific duties that are in the best interest of the principal but may be costly, or not in the best interests of......

Words: 269 - Pages: 2

Free Essay

Information

...business books applying its lessons to "office politics" and corporate strategy. Many Japanese companies make the book required reading for their key executives. The book is also popular among Western business management, who have turned to it for inspiration and advice on how to succeed in competitive business situations. It has also been applied to the field of education. The Art of War has been the subject of various law books and legal articles on the trial process, including negotiation tactics and trial strategy The book art of war by Sun Tzu is a very interesting subject matter for strategies. Although the book is written from a military perspective a lot of the information is universal for anyone involved in strategy. A lot of what is presented is common sense but it is still very good information. The book is written in an unusual way that is more like a form of scripture than mere advice. It is perhaps easy to see why the art of war is the basis of so many strategic management plans. In the book Tzu said "there is no instance of a country having benefited from prolonged warfare." Although this statement was clearly intended from a purely military stand point I think it is something everyone can relate to. In essence warfare is a state that is reached when an agreement cannot be reached any other way. Alternatively it maybe a hostile takeover of territory. Either way it is an extreme situation that is not intended to be used for a prolonged period. In the......

Words: 531 - Pages: 3

Free Essay

Information

...and prevents the air from escaping through the tyre. 5) The bead - is considered the foundation of the tyre. It anchors the bead on the rim. 6) The body ply restricts the pressure which ultimately carries the load. It also transmits the forces (torque, torsion, etc.) from the belts to the bead and eventually to the rim. 7) The steel belts are layers of steel cord wires located between the tread and the body ply. Off road tyres can have up to five belts. Road tyres typically have one or two. The steel wire of the belts run diagonally to the direction of motion. The belts increase the rigidity of the tread which increases the cut resistance of the tyre. TYRE SIZE MARKINGS Tyre size markings include references to the following information a. The section width of the tyre (either in inches of millimetres). b. The types of tyre construction and the rim diameter in inches. c. There is often a reference to the 'aspect ratio' of the tyre - that is a ratio of the tyre's height compared to its width. Tyre size marking example 1: 11R22.5 11---means 11 inches (section width) R-----means radial construction 22.5---means rim diameter 22.5 inches Tyre size marking example 2: 295/80R22.5 295---means 295mm (section width) 80----means Aspect ratio (profile) of the tyre - section height 80% of its section width i.e Section height/Section width*100% R----means radial construction 22.5rim diameter 22.5 inches Example : 205/55 R 16 and Alternative......

Words: 1025 - Pages: 5

Premium Essay

Information

...Western Governors University Create a written proposal for a new information management system Project: Electronic Medical Record System Upgrade Prepared for: Western Governors University Hospital Prepared by: Emilie Reid, RN Western Governors University Hospital is in need of implementing an electronic medical record (eMAR) system. Currently they are using a paper documentation system. The two systems currently being considered are Meditech and Epic. This proposal will compare both systems to explore which will be selected and the most practical for Western Governors University Hospital to adopt. The current hospital record management system is paper based requiring several paper forms containing various information from different interdisciplinary teams incorporated from a patients history of hospital stays. Often, forms are not updated to reflect current patient information, lost between departments or vital information is not correctly incorporated. It is also common practice that multiple copies of the same information exist within the hospital setting posing a risk for inconsistencies of data sources. Within a hospital setting it is imperative that procurement, management and recovery of large volumes of information be easily accessible to anyone with direct medical contact with a patient. Such information would include; patient medical and personal information, health history, staff information, medications, allergies, labs and testing results as......

Words: 2004 - Pages: 9

Premium Essay

Information

...Unit Name: Business & Finance Ethics Unit Code: BBC1001 Year: 2015 Semester: 2 Location: City Flinders Prepared by: Dr Michelle Fong Welcome Welcome to this unit of study. This Unit Guide provides important information and should be kept as a reference to assist with your studies. This Guide includes information about your reading and resources, independent learning, class activities and assessment tasks. It is recommended that you read this Guide carefully: you will be expected to manage your learning as you work towards successful study. Detailed information and learning resources for this unit have also been provided on the Unit website on WebCT/VU Collaborate which can be reached via the Student Portal at vu.edu.au/student-tools/myvu-student-portal It is important that you access your Unit website regularly. Please also refer to information provided on the Student Portal that supports studying at VU. Acknowledgement of Country We respectfully acknowledge and recognise the traditional owners, their Elders past and present, their descendants and kin as the custodians of this land. Contents Welcome Acknowledgement of Country Introduction to the unit ............................................................................................................................................3 Key staff ............................................................................................................................................................3 Required......

Words: 5756 - Pages: 24

Premium Essay

Information

...seemingly eternal longevity, the Chanel brand is unequaled.  In good times and bad, this brand remains strong as a symbol of a life lived in all the right places, doing all the right things. [pic] 5th Dimension – RUGGEDNESS Interestingly, consumers pick up on this personality dimension quite well.  Rugged brands are seen as outdoorsy and tough.  The North Face has built an empire by outfitting people who actually do scary outdoorsy things, and those who just like to look good on the streets of NYC. [pic] The sources from where I, collected the information for the assignment- • From course materials, provided by our teacher • Strategic Brand Management by Kevin Lane Keller • Principles of Marketing by Philip Kotler The online source from where I collected information- • www.learnmarketing.net • www.google.com ( as search engine), • www.yahoo.com ( as search engine) [pic]...

Words: 852 - Pages: 4