Factorial of a number data segment x1 db 4 fact dw ? data ends

Slides:



Advertisements
Similar presentations
Defining and processing tables
Advertisements

Program.-(9)* Write a program Input two numbers from keyboard and multiply of given values using by variables. Input value No 1 input value No2 Multiply.
Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
Assembly Programming Notes for Practical2 Munaf Sheikh
EDUSAT SESSION FOR ADVANCED MICROPROCESSOR (EC54) Date: Session VII Topic: Programming Examples Faculty: Anita Kanavalli MSRIT.
Subroutines: Passing Arguments Using the Stack. Passing Arguments via the Stack Arguments to a subroutine are pushed onto the stack. The subroutine accesses.
第 4 章习题参考答案: 2 、取 SIZE 属性 A1——2 字节( 4 ) A2——3 字节( 6 ) A3——20 字节( 40 ) A4——4 字节( 60 ) 4 、 L=6 5 、 PLENTH=22, 可用于确定循环次数。 7 、( AX ) =1 ( BX ) =20 ( CX ) =1.
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
Direct video practice and Keyboard Operations
IP high IP low IP high IP low BP high BP low IP high IP low BP high BP low FL high FL low CS high CS low IP high IP low _TEXTsegment byte public ‘CODE’
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
7-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Introduction to Assembly.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Kip Irvine: Assembly Language for Intel-Based Computers
Assembly Language – Lab 5
Procedures and the Stack Chapter 5 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7)
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
String-Introduction String is a series of bytes or a series of words in sequential memory locations. Index registers - SI (Data segment) - DI (Extra segment)
Overview of Assembly Language Chapter 4 S. Dandamudi.
ICS312 Set 14 MACROS. Macros The program structure is similar to that for procedures. As for procedure names, macro names represent a group of instructions.
Strings, Procedures and Macros
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
Writing and using procedures
Chapter 8 Advanced Programming Applications Objectives: Linking separate object files together Creating and using an object code library Predicting the.
Processing String Data and Binary Data (continue)
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6.
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
Assembly Programming Notes for Practical 1
Review of Assembly language. Recalling main concepts.
Multi-module programming. Requirements of an assembly language module when it is linked with another module PUBLIC directive - it exports to other modules.
Irvine, Kip R. Assembly Language for Intel-Based Computers. Chapter 7: Integer Arithmetic Slides to Accompany Assembly Language for Intel-Based Computers,
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 6.
BITS Pilani Pilani Campus Pawan Sharma Lecture /12/ EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
Chapter 5: Procedures and Interrupts
1 Using the Assembler Chapter – 4(A). 2 Exchanging Two Variables title Exchange Two Variables (Exchange.asm).model small.stack 100h.data value1 db 0Ah.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman.
Assembly language programming
Multi-module programming
Introduction to assembly programmıng language
Format of Assembly language
COURSE OUTCOMES OF Microprocessor and programming
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Additional Assembly Programming Concepts
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
INSTRUCTION SET.
Assembly Language Programming Part 2
Computer Organization & Assembly Language
(The Stack and Procedures)
اصول اساسی برنامه نویسی به زبان اسمبلی
Chapter 4: Instructions
שפת סף וארכיטקטורה של מעבד 8086
Programming 8086 – Part IV Stacks, Macros
ارايه دهنده : حسن عسكرزاده
8086 Registers Module M14.2 Sections 9.2, 10.1.
اصول اساسی برنامه نویسی به زبان اسمبلی
Microprocessor Lab CSL1543 0:0:2
Microprocessor and Assembly Language
(The Stack and Procedures)
Microprocessor Lab CSL1543 0:0:2
Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
UNIT-II Assembly Language Programs Involving Logical
(The Stack and Procedures)
By Nasser Halasa Assembly Language.
Chapter 8: Instruction Set 8086 CPU Architecture
UNIT-II ADDRESSING MODES & Instruction set
Procedures & Macros Introduction Syntax Difference.
Procedures and Macros.
Presentation transcript:

Factorial of a number data segment x1 db 4 fact dw ? data ends code segment assume cs:code, ds:data start: mov ax,data mov ds,ax mov ax,0001h mov cl,x1 call facto jmp exit facto proc near mul cl dec cl cmp cl,01h jz label1 call facto label1: ret facto endp exit: mov fact,ax mov ah,4ch int 21h code ends end start

Writing and Calling Far Procedure code segment assume cs:code,ds:data,ss:stack_seg …… call mul .. code ends procedures segment mul proc far assume cs:procedures mul endp procedures end

Factorial of a number using Far procedure stackseg segment stack dw 40 dup(0) tos label word stackseg ends dataseg segment public num db 5 res dw ? dataseg ends procedures segment public extrn fact:far procedures ends codeseg segment public assume cs:codeseg,ds:dataseg,ss:stackseg start:mov ax,dataseg mov ds,ax mov ax,stackseg mov ss,ax lea sp,tos mov al,1 mov ah,00 mov cl,num call fact mov res,ax mov ax,4c00h int 21h codeseg ends end start

; procedure which is called from other program public fact procedures segment public fact proc far assume cs:procedures cmp cl,00h jne l1 mov ah,00 ret l1: cmp cl,01h jne l2 mov ah,00 ret l2: mul cl dec cl jnz l2 fact endp procedures ends end

MACRO When repeated group of instructions is too short or not appropriate to be written as a proc.,then we use macro. Macro is a group of instructions we bracket and give a name at the start of the program. Each time we call macro,the assembler will insert the set of instructions in place of call.(called as expanding macro) Assembler will generate the machine codes for the set of instructions each time macro is called.

Syntax: macroname MACRO ………… Syntax: macroname MACRO ………….. ENDM passing parameters to macro Syntax: Macroname MACRO parameters ….

Assume cs:procedures, ds:patient_parameters Push_all ; macro call Example: Breath_rate proc FAR Assume cs:procedures, ds:patient_parameters Push_all ; macro call Mov ax,patient_parameters ;initialize data Move DS,AX ;segment register Push_all MACRO Pushf Push ax Push bx Push cx Push bp Push si Push di Push ds Push es Push ss ENDM

str1 db "Enter string:$" str11 db 15,?,13 dup(0) res db ? data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax mov dx,offset str1 mov ah, 09h int 21h mov dx,offset str11 mov ah,0Ah lea si,str11 mov ah,'$' mov al,' ' mov bl,01h do: cmp [si],ah je down cmp [si],al je go inc si jmp do down: jmp xx go: inc bl xx: mov res,bl mov ah,4ch int 21h