# Assembler Exercises Chapters 4-6 Dr. Gheith Abandah1.

## Presentation on theme: "Assembler Exercises Chapters 4-6 Dr. Gheith Abandah1."— Presentation transcript:

Assembler Exercises Chapters 4-6 Dr. Gheith Abandah1

Exercise 1 z = x + y; Dr. Gheith Abandah2

Exercise 1 movf x, 0 addwf y, 0 movwf z Dr. Gheith Abandah3

Exercise 2 z = x + y;//16-bit numbers Dr. Gheith Abandah4

Exercise 2 movf x_lo, 0 addwf y_lo, 0 movwf z_lo btfsc status, C incf x_hi, 1 movf x_hi, 0 addwf y_hi, 0 movwf z_hi Dr. Gheith Abandah5

Exercise 3 sum = 0; for (i=0; i<10; i++) sum += A[i]; Dr. Gheith Abandah6

Exercise 3 A equ20 movlw 0a movwf counter movlw A movwf fsr clrw Loopaddwf indf,0 incf fsr decfsz counter goto Loop movwf sum Dr. Gheith Abandah7

Assignment Study Section 5.9: The ping-pong program Dr. Gheith Abandah8

Exercise 4 z = (x + y) - q; Dr. Gheith Abandah9

Exercise 4 movf x, 0 addwf y, 0 movwf z movf q, 0 subwf z, 1 Dr. Gheith Abandah10

Exercise 5 z = x-3; Dr. Gheith Abandah11

Exercise 5 movlw 3 subwf x, 0 movwf z Dr. Gheith Abandah12

Exercise 6 z = x<<3; Dr. Gheith Abandah13

Exercise 6 bcf status, C rlf x, 1 bcf status, C rlf x, 1 bcf status, C rlf x, 0 movwf z Dr. Gheith Abandah14

Exercise 7 z = x && 0x0f; Dr. Gheith Abandah15

Exercise 7 movlw 0f andwf x, 0 movwf z Dr. Gheith Abandah16

Exercise 8 z = x * 4; Dr. Gheith Abandah17

Exercise 8 bcf status, C rlf x, 1 bcf status, C rlf x, 0 movwf z Dr. Gheith Abandah18