Download presentation
Presentation is loading. Please wait.
Published byBuddy Payne Modified over 9 years ago
1
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6
2
Procedures Types Nesting Context Save/Restore Assembling/Linking Multiple Source Files Parameter Passing Register, Memory, Stack Pointers Arithmetic Operands Instructions Objectives
3
Procedures Why? Syntax PROC / ENDP CALL / RET Operation CALL types Intrasegment IP relative Indirect Intersegment Direct Indirect RET types
4
Procedures Nesting and Single Module Programs Example and stack operation Context Save / Restore Caller vs. procedure Course documentation requirements PUSH / POP balance and order Testing & Debugging Procedures Interface Implementation Integration
5
Multiple File Assembly/Linking Each assembly source file is assembled independently – linker then joins together. How to make it all work… EXTRN directive PUBLIC directive GLOBAL directive Segment COMBINE types Addressability issues TASM/TLINK commandscommands Example source code wk6main.asm wk6proc.asm wk6main.asmwk6proc.asm
6
Parameter Passing Register Passing Memory Passing Using Pointer Parameters Example Stack Passing Reentrant procedures Using a stack frame Parameters Local variables Example ENTER / LEAVE
7
Arithmetic Operands Unsigned Binary Integers Byte Word Double-word Signed Binary Integers Byte Word Double-word Unpacked BCD Packed BCD Arithmetic Overflow Multi-precision Operations
8
Unsigned Arithmetic Operations Most also used for signed arithmetic MnemonicOperandsFunction OSZAPC ADD dst, srcAddition ADC dst, srcAdd with carry INC dstIncrement by 1 - SUB dst, srcSubtraction SBB dst, srcSubtract with borrow DEC dstDecrement by 1 - CMP dst,srcCompare MUL srcUnsigned multiplication ???? DIV srcUnsigned division??????
9
Signed Arithmetic Operations All signed numbers represented in 2’s- complement format Can use the general math operations discussed for unsigned numbers, plus some specific signed arithmetic instructions… MnemonicOperandsFunction OSZAPC NEG dstNegate------ CBW noneConvert byte to word??? ? CWD noneConvert word to double word ------ IMUL srcInteger multiplication ???? IDIV srcInteger division??????
10
BCD Arithmetic Operations Unpacked BCD Packed BCD Mnemonic Use Inherent Operands Function OSZAPC AAA ASCII adjust for addition??? ? AAS ASCII adjust for subtraction??? ? AAM ASCII adjust for multiplication? ? ? AAD ASCII adjust for division? ? ? DAA Decimal adjust for addition DAS Decimal adjust for subtraction
11
Numeric Conversions BCD Binary Convenient relationship between bit groups and digits Hexadecimal binary is similar, but have to account for 0-9 and A-F (a-f) Binary Decimal No convenient relationship between bit groups and digits Repeated subtraction Division/modulus
12
Wrapping Up Exam 1 will be held on Thursday, October 18, 2001 from 7:15 to 8:45 PM in 132 Noland
13
.186 assume cs:code, ss:stck, ds:data extrn MyProc:PROC public gVar stcksegment db 256 dup (?);256 byte stack toslabel word;top of stack stck ends datasegment public gVardb 0;define variable dataends codesegment public main:mov ax, data;DS addressability mov ds, ax mov ax, stck;SS addressability mov ss, ax mov sp, offset tos;initialize sp main_loop: call MyProc;call external proc jmp main_loop codeends endmain;code entry point wk6main.asmwk6main.asm
14
wk6proc.asmwk6proc.asm.186 assume cs:code, ds:data global MyProc:PROC global gVar:BYTE datasegment public ;empty segment for assume directive dataends codesegment public ;need procedure comment header! MyProcproc inc gVar ret MyProcendp codeends end ;don't define another code entry point! wk6proc.asmwk6proc.asm
15
TASM/TLINK Commands tasm /l /zi wk6main tasm /l /zi wk6proc tlink /v wk6main wk6proc (the executable file will have the same name as the first object file, so in this case the linker will create wk6main.exe) tlink /v wk6main wk6proc, wk6 (the executable file will be named wk6.exe)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.