Riistvarapõhine programmeerimine Loeng 7 Protseduurid Katkestused Tsüklid.

Slides:



Advertisements
Similar presentations
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Advertisements

10-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Subroutine and Interrupt.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Video systems (continue). Practice Modify the program to get a string from a keyboard to display the input string on the middle of the screen with reverse.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
80x86 Instruction Set Dr. Qiang Lin.
Riistvarapõhine programmeerimine Loeng 3 Arvuti programmeerija pilguga Mälu korradus.
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
CS2422 Assembly Language & System Programming November 2, 2006.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Flow Control Instructions
Kip Irvine: Assembly Language for Intel-Based Computers
Introduction to Computer Engineering by Richard E. Haskell Interrupts Module M17.3 Sections 11.3, 14.1.
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Lab 5 Part C Write to the screen a character string that uses a ‘$’ to indicate the end of the string. Do not write the ‘$’ to the screen. Use DOS Interrupt.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
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.
Chapter 3 Examining Computer Memory and Executing Instructions.
1 Chapter 5: Procedures and Interrupts Assembly Language for Intel-Based Computers, Kip R. Irvine 3rd edition 3/17/2000.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Lecture 14 Basic I/O Interface Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Strings, Procedures and Macros
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Writing and using procedures
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 5 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
EEL 3801 Part IV The Assembler. OFFSET Operator Returns address of variable used as operand. Actually, it represents the offset from the beginning of.
In Class Program Write, assemble and test a program: –Use the DB directive to define the following list of numbers and name it array: 31h, 32h, 33h, 34h.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
BITS Pilani Pilani Campus Pawan Sharma Lecture EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
BITS Pilani Pilani Campus Pawan Sharma Lecture /12/ EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA 1 Assembly Language Programming.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Stack Operations Dr. Hadi AL Saadi.
Format of Assembly language
Data Transfers, Addressing, and Arithmetic
Microprocessor and Assembly Language
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Assembly IA-32.
Assembly Language Programming Part 2
Microprocessor and Assembly Language
(The Stack and Procedures)
Chapter 3 Addressing Modes
اصول اساسی برنامه نویسی به زبان اسمبلی
UNIT: 2 INSTRUCTION SET OF 8086.
Symbolic Instruction and Addressing
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Stack and Subroutines Module M17.1 Section 11.2.
ارايه دهنده : حسن عسكرزاده
8086 Registers Module M14.2 Sections 9.2, 10.1.
(The Stack and Procedures)
Microprocessor Lab CSL1543 0:0:2
Symbolic Instruction and Addressing
Morgan Kaufmann Publishers Computer Organization and Assembly Language
X86 Assembly Review.
High-level language structures
(The Stack and Procedures)
By Nasser Halasa Assembly Language.
The JUMP GROUP Unconditional Jump (JMP).
Presentation transcript:

Riistvarapõhine programmeerimine Loeng 7 Protseduurid Katkestused Tsüklid

28/07/2004 ID218 Riistvaralähedane programmeerimine2 Protseduurid Call Ret

28/07/2004 ID218 Riistvaralähedane programmeerimine3 Call I Near: call disp16 ;direct, 16 bit relative call mem16 ;indirect, 16 bit memory pointer call reg16 ;indirect, 16 bit register pointer Far: call adrs32 ;direct, 32 bit segmented address call mem32 ;indirect, 32 bit memory pointer

28/07/2004 ID218 Riistvaralähedane programmeerimine4 Call II Far Call CS -> stack IP -> stack Uus segment -> CS Uus IP -> IP

28/07/2004 ID218 Riistvaralähedane programmeerimine5 Call III Near Call IP -> stack Uus IP -> IP

28/07/2004 ID218 Riistvaralähedane programmeerimine6 Call IV call disp16 Sub1 proc near ret Sub1 endp... call Sub1

28/07/2004 ID218 Riistvaralähedane programmeerimine7 Call V call mem16 SubPtr1wordSub1... Sub1 proc near ret Sub1 endp... call SubPtr1

28/07/2004 ID218 Riistvaralähedane programmeerimine8 Call VI call reg16 Sub1 proc near ret Sub1 endp... lea cx, Sub1 call cx

28/07/2004 ID218 Riistvaralähedane programmeerimine9 Call VII call disp32 Sub2 proc far ret Sub2 endp... call Sub2

28/07/2004 ID218 Riistvaralähedane programmeerimine10 Call VIII call mem32 SubPtr1dwordSub2... Sub2 proc far ret Sub2 endp... call SubPtr2

28/07/2004 ID218 Riistvaralähedane programmeerimine11 Call IX call 2[bx] call Variable [bx] call [bx][si] call Variable[bx][si] Erinevad adresseerimisviisid lubatud

28/07/2004 ID218 Riistvaralähedane programmeerimine12 Ret I pop ax jmp ax

28/07/2004 ID218 Riistvaralähedane programmeerimine13 Ret II Near: Ret (Retn) popIP Far Retf popCS popIP

28/07/2004 ID218 Riistvaralähedane programmeerimine14 Ret III Sub: push ax push bx. pop bx ret. call Sub

28/07/2004 ID218 Riistvaralähedane programmeerimine15 Ret IV Stack (pinu): CallSubRet IP IPBxAxAxIP AxIPIP IP

28/07/2004 ID218 Riistvaralähedane programmeerimine16 Ret V Retconst Sub:proc... ret 2 endp... push param1 pushparam2 callSub

28/07/2004 ID218 Riistvaralähedane programmeerimine17 Ret VI Ret 2 CallSubRet 2 IPIPValue1Param2Param1Value1

28/07/2004 ID218 Riistvaralähedane programmeerimine18 Katkestused I Int Iret

28/07/2004 ID218 Riistvaralähedane programmeerimine19 Katkestused II int nn 0<nn<255 nnInterrupt vector Interrupt Vector Table

28/07/2004 ID218 Riistvaralähedane programmeerimine20 Katkestused III MS-DOS interrupt 21h ah-function code mov ah, 4Ch ;DOS terminate code int 21h ;DOS call

28/07/2004 ID218 Riistvaralähedane programmeerimine21 Katkestused V

28/07/2004 ID218 Riistvaralähedane programmeerimine22 Katkestused VI BIOS: Int 5 Print Screen operation. Int 10h Video display services. Int 11h Equipment determination. Int 12h Memory size determination. Int 13h Diskette and hard disk services. Int 14h Serial I/O services. Int 15h Miscellaneous services. Int 16h Keyboard services. Int 17h Printer services. Int 18h BASIC. Int 19h Reboot. Int 1Ah Real time clock services.

28/07/2004 ID218 Riistvaralähedane programmeerimine23 Katkestused VII PutChar prints the character in the AL register to the display. PutCharproc pushax;Preserve value in AH movah, 0eh;BIOS call to print a ;character. int10h popax;Restore AH's value. ret PutCharendp

28/07/2004 ID218 Riistvaralähedane programmeerimine24 Katkestused VIII GetChar reads a single key from the keyboard and puts it in the AL register. GetCharproc movah, 0;BIOS call to read a ;key. int16h ret GetCharendp

28/07/2004 ID218 Riistvaralähedane programmeerimine25 Katkestused IX INTCall 2 bytes2-6 bytes Push far returnPush return Push flags Iret ret popf

28/07/2004 ID218 Riistvaralähedane programmeerimine26 Tsüklid I Loop Loope Loopne Loopz Loopnz

28/07/2004 ID218 Riistvaralähedane programmeerimine27 Tsüklid II Loop: Deccx Jnzlbl Cx korda Ei mõjuta lipud

28/07/2004 ID218 Riistvaralähedane programmeerimine28 Tsüklid III mov cx, 255 ArrayLp: mov Array[cx], cl loop ArrayLp mov Array[0], 0 Array = 0, 1, 2, 3,...

28/07/2004 ID218 Riistvaralähedane programmeerimine29 Tsüklid VI LOOPE/LOOPZ cx := cx - 1 if ZeroFlag = 1 and cx != 0, goto target Ei mõjuta lipud Aeglane

28/07/2004 ID218 Riistvaralähedane programmeerimine30 Tsüklid VII Otsime massiivist nullist erineva elemendi: mov cx, 16 ;Max 16 array elements. mov bx, -1 ;Index into the array (note ;next inc). SearchLp: inc bx ;Move on to next array ;element. cmp Array[bx], 0 ;See if this element ;is zero. loope SearchLp ;Repeat if it is. je AllZero ;Jump if all elements ;were zero. AllZero:...

28/07/2004 ID218 Riistvaralähedane programmeerimine31 Tsüklid VIII LOOPNE/LOOPNZ cx := cx - 1 if ZeroFlag = 0 and cx  0, goto target Ei mõjuta lipud Aeglane

28/07/2004 ID218 Riistvaralähedane programmeerimine32 Tsüklid IX Otsime massiivist null-elemendi: mov cx, 16 ;Maximum # of array ;elements. mov bx, -1 ;Index into array. LN0: inc bx ;Move on to next array ;element. cmp Array[bx],0 ;Does this element ;contain zero? loopne LN0 ;Quit if it does, or ;more than 16 bytes.

28/07/2004 ID218 Riistvaralähedane programmeerimine33 Tsüklid X Ootame, millal välisoperatsioon lõpeb, seda näitab pordi 379h bit 7. mov dx, 379h WaitNBusy: in al, dx ;Get port test al, 80h ;See if bit #7 is one jne WaitNBusy ;Wait for “not busy”

28/07/2004 ID218 Riistvaralähedane programmeerimine34 Tsüklid XI Ootame, millal välisoperatsioon lõpeb, seda näitab pordi 379h bit 7. mov dx, 379h ;Input port address mov cx, 0 ;Loop 65,536 times and ;then quit. WaitNBusy: in al, dx ;Get data at port. test al, 80h ;See if busy loopne WaitNBusy ;Repeat if busy and no ;time out. jne TimedOut ;Branch if CX=0 because ;we timed out.

28/07/2004 ID218 Riistvaralähedane programmeerimine35 Tsüklid XII WHILE boolean expression DO statement; I := 0; WHILE (I<100) do I := I + 1; mov I, 0 WhileLp: cmp I, 100 jge WhileDone inc I jmp WhileLp WhileDone:

28/07/2004 ID218 Riistvaralähedane programmeerimine36 Tsüklid XIII LOOPLoop.... EndLoop READ(ch) IF ch = ‘.’ THEN BREAK; WRITE(ch); ENDLOOP; LOOP1: call getchar cmp al, ‘.’ je EndLoop call putchar jmp LOOP1 EndLoop:

28/07/2004 ID218 Riistvaralähedane programmeerimine37 Tsüklid XIV FOR var := start TO stop DO stmt; FOR I := 0 to 7 do write(ch); mov cx, 7 LP: mov al, ch call putcchar loop LP

28/07/2004 ID218 Riistvaralähedane programmeerimine38 Tsüklid XV mov cx, 8 Loop1: mov cx, 4 Loop2: stmts loop Loop loop Loop1 Vale!!!

28/07/2004 ID218 Riistvaralähedane programmeerimine39 Tsüklid XVI mov cx, 8 Loop1: push cx mov cx, 4 Loop2:..... loop Loop2 pop cx..... loop Loop1 Õige !!!

28/07/2004 ID218 Riistvaralähedane programmeerimine40 Kokkuvõte I Protseduurid: Call Proc ret endp

28/07/2004 ID218 Riistvaralähedane programmeerimine41 Kokkuvõte II Katkestused: Int nn iret

28/07/2004 ID218 Riistvaralähedane programmeerimine42 Kokkuvõte III Tsükklid: Loop Loope Loopz Loopne Loopnz