120 likes | 137 Views
Ştefan Stăncescu. PART I SISTEM UTILITIES. LECTURE 5 MACROPROCESSING. MACROPROCESSING. Macroinstruc tion => new instriction for easy use of frequent instructions lists . M acroproce s so r => program that ease macroinstructions definition and macroinstructions mean of use
E N D
Ştefan Stăncescu PART ISISTEM UTILITIES LECTURE 5 MACROPROCESSING
MACROPROCESSING • Macroinstruction=> new instriction for • easy use of frequent instructions lists. • Macroprocessor => program that ease • macroinstructions definition and • macroinstructions mean of use • Macroprocessor first functionalities • macro definition, macro call • and macro development at macro call
MACROPROCESSING • macro definitionis • a program line with the macroinstruction name + • the generic list of operands (parameters) • and all instruction listlines (macro body). • macro call is • a program line w/macroinstruction name + current formal parameter list • macro development is • the apel macro call replacement with • macro body
MACROPROCESSING • Macro definition: • MACRO add_a_square sum, square • move rega,number • mul rega,rega • add sum,rega • ENDMACRO • Macro call: • ... • sum=0 • add_a_square sum,no1 • add_a_square sum,no2 • add_a_square sum,no3 • add_a_square sum,no4 • ...
MACROPROCESSING • ... • sum=0 • C add_a_square sum,no1 • move rega,no1 • mul rega,rega • add sum,rega • C add_a_square sum,no2 • move rega,no2 • mul rega,rega • add sum,rega • C add_a_square sum,no3 • move rega,no3 • mul rega,rega • add sum,rega • C add_a_squaresum,no4 • move rega,no4 • mul rega,rega • add sum,rega • ...
MACROPROCESSING • PROCEDURES • add_a_square : • move rega,number • mul rega,rega • add sum,rega • ret • w/procedures: • ... • move sum,0 • move number,no1 • call add_a_square • move number,no2 • call add_a_square • move number,no3 • call add_a_square • move number,no4 • call add_a_square • ...
MACROPROCESSING • MACRO irp parameter,<parameter list> • corp_irp • ENDMACRO • ... • sum=0 • irp number,<no1,no2,no3,no4> • move rega,number • mul rega,rega • add sum,rega • ENDMACRO • ... • Or with macro nesting: • ... • sum=0 • irp number,<no1,no2,no3,no4> • add_a_square sum,number • ENDMACRO • ...
MACROPROCESSING • With iterated procedures • ... • move sum,0 • move i,N • loop: move number,n(i) • call add_a_square • dcr i • jmpnz i,loop • ... • CONCLUSIONS: • Procedures: easy programming, short code, length invariable with n - number of calls, time consuming call/ret. • Macro: no jumps in memory space, less processing time, much more memory space, no acceptable in loops
MACROPROCESSOR • DEFTAB, define table, a macro list, for each with • macro call template line prototype + • + macro body + • + with list of generic parameters replaced with order no. • NAMTAB, name table with • call macro name + DEFTAB definition address • ARGTAB, argument(formal parameter) table • temporary memory argument stack • written at macro call • read in macro development
MACROPROCESSOR • ARGTAB: • ... • adaugă_un_pătrat suma,nr1 • adaugă_un_pătrat suma,nr2 • adaugă_un_pătrat suma,nr3 • adaugă_un_pătrat suma,nr4 • ...
MACROPROCESSOR • 1.L.L. Beck, “System Software: An introduction to systems programming”, Addison Wesley. 3’rd edition, 1997. • 2.John R. Levine, "Linkers and Loaders", Morgan Kauffman, 2000 • 3.*** MASM 8.0 http://www.microsoft.com