Chapter 1 Context of Assembly Language Slides to

Chapter 1: Context of Assembly Language Slides to Accompany Assembly Language for Intel-Based Computers, Third Edition Copyright 1999 -2000, Prentice-Hall Incorporated Updated 08/00

Table 1. Software Hierarchy Levels.

Essential Tools • An assembler is a program that converts source-code programs into a machine language (object file). • A linker joins together two or more object files and produces a single executable file. • A debugger loads an executable program, displays the source code, and lets the programmer step through the program one instruction at a time, and display and modify memory.

Figure 1. Machine Language Generation by ASM and HLL programs.

Table 2. Comparison of Assembly Language to HLLs.

Figure 2. Assembly Language Subroutines Used as Hardware Interfaces.

Machine Language • Consists of binary numbers • The "native" language of the computer • Each ML instruction contains an op code (operation code) and zero or more operands. • Examples: Opcode Operand Meaning ------------------------40 increment the AX register 05 0005 add 0005 to AX

Page 7: Bits, Bytes, and Doublewords: Each 1 or 0 is called a bit.

Table 3. Storage Sizes and Ranges of Unsigned Integers.

Table 4. Digits in Various Number Systems.

Page 9. ASCII Digit String.

Table 5. Binary Bit Position Values.

Figure 3. Converting Binary to Decimal.

Table 6. Binary, Decimal, and Hexadecimal Equivalents.

Table 7. Powers of 16, in Decimal.

Figure 4. Converting 3 BA 4 Hexadecimal to Decimal.

1. 2. 4 Signed Numbers

Table 8. Signed Integer Storage and Ranges.

1. 2. 5 Character Storage Page 14. ASCII Representation of 123:

1. 3 Introducing Assembly Language • An instruction is a symbolic representation of a single machine instruction • Consists of: – – label mnemonic operand(s) comment always optional always required by some instructions always optional • Examples: start: mov ax, 20 inc bx stc ; initialize the AX register ; increment the BX register ; set the Carry flag

Figure 5. Sample Program Written in Debug.

Running DEBUG. EXE, Assembling a Program C: >debug -A 100 assemble, starting at offset 100 0 AFE: 0100 mov ax, 5 0 AFE: 0103 add ax, 10 0 AFE: 0106 add ax, 20 0 AFE: 0109 mov [120], ax 0 AFE: 010 C int 20 0 AFE: 010 E Press ENTER to return to command mode

Tracing the Sample Program. -T AX=0005 BX=0000 CX=0000 DX=0000 SP=FFEE DS=0 AFE ES=0 AFE SS=0 AFE CS=0 AFE IP=0103 0 AFE: 0103 051000 ADD BP=0000 SI=0000 DI=0000 NV UP EI PL NZ NA PO NC AX, 0010 -T AX=0015 BX=0000 CX=0000 DX=0000 SP=FFEE DS=0 AFE ES=0 AFE SS=0 AFE CS=0 AFE IP=0106 0 AFE: 0106 052000 ADD BP=0000 SI=0000 DI=0000 NV UP EI PL NZ NA PO NC AX, 0020 -T AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE DS=0 AFE ES=0 AFE SS=0 AFE CS=0 AFE IP=0109 0 AFE: 0109 A 32001 MOV [0120], AX BP=0000 SI=0000 DI=0000 NV UP EI PL NZ NA PE NC
![Tracing the Sample Program (2) MOV [0120], AX -D 120, 121 0 AFE: 0120 Tracing the Sample Program (2) MOV [0120], AX -D 120, 121 0 AFE: 0120](http://slidetodoc.com/presentation_image_h2/67f722b1494cb7dcfce54cba62a4924d/image-24.jpg)
Tracing the Sample Program (2) MOV [0120], AX -D 120, 121 0 AFE: 0120 35 00 AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE DS=0 AFE ES=0 AFE SS=0 AFE CS=0 AFE IP=010 C 0 AFE: 010 C CD 20 INT -G Program terminated normally 20 BP=0000 SI=0000 DI=0000 NV UP EI PL NZ NA PE NC

Table 9. Commonly Used Debug Commands.

The End
- Slides: 26