Compute Sum and Implement Interrupts in Assembly Language Programming

lab 7 n.w
1 / 21
Embed
Share

Learn how to write programs in assembly language to compute sums, find averages, and add arrays. Explore the concept of interrupts, including hardware and software interrupts, for efficient programming. Enhance your programming skills with practical examples and instructions.

  • Assembly Language
  • Interrupts
  • Programming
  • Assembly Programming
  • Sum Calculation

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lab 7 Loop Instruction Interrupts . . :

  2. Loop Instruction Q: 1+2+3+..+9 Mov cl,9 Top: add dl,cl Loop Top ret

  3. Q: Write a program in assembly language to compute the sum of array a1 elements? mov cx, 5 sum: add al,a1[si] inc si loop sum ret a1 db 1, 2, 3, 4, 5

  4. Q: Write a program in assembly language to compute 2+4+6+8? mov cx, 4 mov bl,2 sum: add al,bl add bl,2 loop sum ret

  5. Q: Write a program in assembly language to compute 2+4+6+..+N?

  6. Q: Write a program in assembly language to compute the AV of array a1 elements?

  7. Q: Write a program in assembly language to add a1 array to a2 and put result in a3 array? mov cx, 4 sum: mov al,a1[si] add al,a2[bx] mov a3[di], al inc si inc bx inc di loop sum ret a1 db 1, 2, 5, 6 a2 db 3, 5, 6, 1 a3 db ?, ?, ?, ?

  8. Compute 5! MOV AL,01 MOV CL ,05 FACT: MUL CL LOOP FACT RET

  9. Interrupts Interrupts Hardware Interrupts Software Interrupts can be seen as a number of functions. These functions make the programming much easier, instead of writing a code to print a character you can simply call the interrupt and it will do everything for you.

  10. INT instruction To make software interrupt INT Value The value number can be between 0 to 255 (0 to 0FFh)

  11. INT instruction INT 10h The following example uses INT 10h sub-function 0Eh. This functions displays a character on the screen.

  12. INT instruction ORG 100h MOV AH, 0Eh MOV AL, 'H' ; ASCII code: 72 INT 10h ; print it! RET ; returns to operating system.

  13. INT instruction ORG 100h MOV AH, 0Eh MOV AL, 'H' ; ASCII code: 72 INT 10h ; print it! MOV AL, 'e' ; ASCII code: 101 INT 10h ; print it! MOV AL, 'l' ; ASCII code: 108 INT 10h ; print it! MOV AL, 'l' ; ASCII code: 108 INT 10h ; print it! MOV AL, 'o' ; ASCII code: 111 INT 10h ; print it! RET ; returns to operating system.

  14. INT instruction INT 21h INT 21h use many sub-functions such as: 01h to read one value of character from keyboard 02h to write one character on the screen. Every sub-function value was include in AH register

  15. INT instruction EX1: INT 21h for 01h sub-function MOV AH, 01 INT 21H Ret

  16. MOV AH, 01 INT 21H MOV DL,AL INT 21H Ret

  17. INT instruction EX2: INT 21h for 02h sub-function Input: load 02 into AH register Load ASCII code into DL register Output: Copy ASCII code into AL register

  18. INT instruction MOV AH, 02 mov dl,72 INT 21H MOV AH , 02H MOV DL , '?' INT 21H Ret Ret

  19. Library of common functions Library of common functions - - emu emu8086 8086.inc .inc

  20. include emu8086.inc ORG 100h PRINT 'Welcome' GOTOXY 10, 5 PUTC 65 PUTC 'B' RET ; 65 is an ASCII code for 'A' ; return to operating system.

  21. Architecture

More Related Content