Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Opdracht 7 - Subroutines en macro's
- -----------------------------------
- +----------------+
- | Schrijf cijfer |
- +----------------+
- Schrijfcijfer macro cijfer
- local gtNegen, print
- movlw cijfer ; cijfer --> WREG
- movwf getal ; WREG --> getal
- movlw 0x0A ; 0x0A --> WREG
- cpfslt getal ; Skip if getal < WREG (getal < 0x0A)
- bra gtNegen ; else go gtNegen
- movlw '0' ; '0' --> WREG
- addwf getal ; '0' + getal --> getal
- bra print ; go print
- gtNegen:
- movlw 0x37 ; 0x37 --> WREG
- addwf getal ; 0x37 + getal --> getal
- print:
- movff getal, LATD ; getal --> LATD
- movlw 0x46 ; 0x46 --> WREG
- cpfsgt getal ; Skip if getal > WREG (getal > 0x0F)
- call Epuls ; Druk op LCD
- EndM
- LCD_Init
- LCD_Lijn1
- Schrijfcijfer 0x05
- Scrhijfcijfer 0x0E
- lus:
- bra lus
- +-----------------+
- | Grootste cijfer |
- +-----------------+
- Grootste
- movff getal1, WREG
- cpfsgt getal2 ; Skip if getal2 > getal1
- bra getal1GT2
- movff getal2, WREG
- cpfsgt getal3
- bra druk2
- bra druk3
- getal1GT2:
- cpfsgt getal3 ; Skip if getal3 > getal1
- bra druk1
- bra druk3
- druk1:
- Schrijfcijfer getal1
- bra einde
- druk2:
- Schrijfcijfer getal2
- bra einde
- druk3:
- Schrijfcijfer getal3
- einde:
- return
- **************************************************
- Grootste
- movlw getal1
- cpfslt getal2
- movlw getal2
- cpfslt getal3
- movlw getal3
- Schrijfcijfer WREG
- return
- movlw 0x04
- movwf getal1
- movlw 0x07
- movwf getal2
- movlw 0x08
- movwf getal3
- call Grootste
- lus:
- bra lus
- +---------------+
- | Schrijf tekst |
- +---------------+
- printTekst MACRO adres
- local printString, printCharacter, EindePrintMenu
- movlw UPPER adres
- movwf TBLPTRU
- movlw HIGH adres
- movwf TBLPTRH
- movlw LOW adres
- movwf TBLPTRL
- printString:
- tblrd*+
- tstfsz TABLAT
- bra printCharacter
- bra EindePrintMenu
- printCharacter:
- ;aanvullen om de inhoud van TABLAT op het LCD te plaatsen
- movff TABLAT, LATD
- call Epuls
- bra printString
- EindePrintMenu:
- EndM
- tekst1 db "Hallo Wereld",0
- printTekst tekst1
- tekst2 db "Lorem Ipsum",0
- printTekst tekst2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement