Professional Documents
Culture Documents
Assembly Language
Programming
Objectives
• Assembly language directives versus instructions
• Assemble, link, and run a simple Assembly language program
• Introduction to MASM assembler
• conditional and unconditional jumps and call instructions
• Assembly language programing
• Introduce the emu8086 assembler =compiler
Directives
• Assembly language directive
• Directives (pseudo-instructions) give directions to the assembler about
how it should translate the Assembly language instructions into
machine code.
Stack Segment
• The Following directive reserves 64 bytes of memory for the stack:
.STACK 64
…Directives
Data Segment
• The data segment defines three data items:
• DATA1, DATA2, and SUM.
Note: the MASM we provided uses Ml & LINK16 for Assembly and Linking
…ASSEMBLE, LINK, AND RUN A
PROGRAM
• When the list is printed, the assembler can print the title
of the program on top of each page.
• It is common to put the name of the program immediately after
the TITLE pseudo-instruction.
• And a brief description of the function of the program.
• The text after the TITLE pseudo-instruction cannot be exceed
60 ASCII characters.
The DEBUG program
• Allows to monitor program’s execution closely for debug purpose
• Starting DEBUG type its name in command prompt
C:\>DEBUG <return>
-R Display content of registers
-R CX Display content of CX and prompt for new value
CX 0000
:FFFF Set CX with new value FFFF
C:\>DEBUG <return>
-A <starting address> To enter assembly instructions staring on a specified address
C:\>DEBUG <return>
- U <starting address> <ending address> Un-assemble machine codes in memory locations specified
C:\>DEBUG <return>
- G <starting address> <stop address> Executes instructions between start and stop addresses
C:\>DEBUG <return>
- d <starting address> <end address> Dump memory content for examination
…ASSEMBLE, LINK, AND RUN A PROGRAM
A program and the list file generated when the program was assembled.
Exercise 2
• Write a program that transfers 5
byte of data (20H, 40H, 11H,
1FH, 0CDH) from memory
location with offset of 0000H to
memory location with offset
0021H
(The “ORG” can be used to
assign the offset address during
data definition)
CONTROL TRANSFER INSTRUCTIONS
FAR and NEAR
– "JNZ AGAIN" was assembled as "JNZ 000D", and 000D is the address of the
instruction with the label AGAIN.
• "JNZ 000D" has the opcode 75 and the target address FA.
CONTROL TRANSFER INSTRUCTIONS
short jumps
• This is followed by "MOV SUM,AL", which is located
beginning at offset address 0013.
• 1110:001D 75EA JNZ XXXXH IP+EA(1st byte)=001D+EA=0117 or(17 drop the carry)