1 / 12

ECE 424 Design of Microprocessor-Based Systems

ECE 424 Design of Microprocessor-Based Systems. Introduction to Assembly Language Programming. Haibo Wang ECE Department Southern Illinois University Carbondale, IL 62901. Overview of Assembly Language. Advantages:. Faster as compared to programs written using high-level languages

chinue
Télécharger la présentation

ECE 424 Design of Microprocessor-Based Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 424 Design of Microprocessor-Based Systems Introduction to Assembly Language Programming Haibo Wang ECE Department Southern Illinois University Carbondale, IL 62901

  2. Overview of Assembly Language • Advantages: • Faster as compared to programs written using high-level languages • Efficient memory usage • Control down to bit level • Disadvantages: • Need to know detail hardware implementation • Not portable • Slow to development and difficult to debug • Basic components in assembly Language: Instruction, Directive, Label, and Comment

  3. Example of Assembly Language Program ;NUMOFF.ASM: Turn NUM-LOCK indicator off. .MODEL SMALL .STACK .CODE .STARTUP MOV AX,40H ;set AX to 0040H D1: MOV DS,AX ;load data segment with 0040H MOV SI,17H ;load SI with 0017H AND BYTE PTR [SI],0DFH ;clear NUM-LOCK bit .EXIT END Comments Assembly directive Instructions Assembly directive Label

  4. Instruction Format • General Format of Instructions Label: Opcode Operands; Comment • Label: It is optional. It provides a symbolic address that can be used in branch instructions • Opcode: It specifies the type of instructions • Operands: Instructions of 80x86 family can have one, two, or zero operand • Comments: Only for programmers’ reference • Machine Code Format Opcode Mode Operand1 Operand2 MOV AL, BL 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 Register mode MOV

  5. Assembler Directives • Source File • List File 0000 DATA SEGMENT PARA 'DATA’ ORG 7000H 7000 0010 [00] POINTS DB 16 DUP(?) 7010 00 SUM DB ? 7011 DATA ENDS 0000 CODE SEGMENT PARA 'CODE' ASSUME CS:CODE, DS:DATA ORG 8000H 8000 B8 7000 TOTAL: MOV AX,7000H 8003 8E D8 MOV DS,AX 8005 B0 00 MOV AL,0 ••••••••• DATA SEGMENT PARA 'DATA‘ ORG 7000H POINTS DB 16 DUP(?) SUM DB ? DATA ENDS CODE SEGMENT PARA 'CODE‘ ASSUME CS:CODE, DS:DATA ORG 8000H TOTAL: MOV AX,7000H MOV DS,AX MOV AL,0 ••••••••• CODE ENDS END TOTAL

  6. Assembler Directives • SEGMENT directive • ENDS directive • END directive • ORG directive • DB: Define Byte; DW, …. • ASSUME directive • Specifies the segment register (segment Register) that will be used to calculate the effective addresses for all labels and variables defined under a given segment or group name (segment Name). If CS = 1230H and DS = 5678H, what are the physical memory addresses of label TOTAL and variable SUM?

  7. Assembler Directives • Simplified Segment Directives • Predefined .Mode Types .MODEL SMALL .DATA ORG 7000H POINTS DB 16 DUP(?) SUM DB ? .CODE ORG 8000H TOTAL: MOV AX,7000H MOV DS,AX MOV AL,0 ••••••••• RET END TOTAL * Flat is used for 32-bit addressing

  8. Build Executable Programs library Linker Assembler Source files Syntax check Translate sourcefiles into machine code OBJ files Executable files OBJ files Question: What is the difference between *.com and *.exe files? http://www.faqs.org/faqs/msdos-programmer-faq/part2/section-9.html • Assemblers • Microsoft ML, LINK, & DEBUG • 8086 Emulator • A86 • MASM32 package • •••••••

  9. Microsoft MASM and Debug • Microsoft MASM and Link Programs Syntax check; Translate assembly instructions into machine codes ML /c /Fl numoff.asm Link numoff Build the executable file • Microsoft Debug Program • C:\> debug • a • 0BDF:0100 MOV AX, 40 • 0BDF:0103 • t • AX = 0040 BX = 0000 CX = 0000 DX = 0000 SP = ……………. • ………………………………………….. • - q

  10. 8086/8088 Assembler and Emulator

  11. Difference Between EXE and Binary Files • Source File • List File .model small 0000 .data org 0200H 0200 12 Var1 DB 12H 0000 .code 0000 B8 0000 MOV AX, 0000 0003 8E D8 MOV DS, AX 0005 A0 0100 label1: MOV AL, DS:[0100H] 0008 EB FB JMP label1 end .model small .data org 0010H Var1 DB 12H .code MOV AX, 0000 MOV DS, AX label1: MOV AL, DS:[0100H] JMP label1 end

  12. Difference Between EXE and Binary Files • EXE file • Binary file

More Related