Jump to content

Recommended Posts

Posted

Being new to assembler and learning by example, i'm trying to adapt the Tiny Control app.

I'm trying to create a function to display a single-char bar (as on the MidiBox64) using 7 special chars (0x00 to 0x06) and the standard char 0xFF (which is a complete filled bar, that way i save one char).

I got this far and it works pretty well for values under 112 (bars 1-7)

;; --------------------------------------------------------------------------
;;  print a parameter bar
;;  IN: number of parameter (0x00-0xff) in WREG
;; --------------------------------------------------------------------------
TC_DISPLAY_Page_PrintBar
      lfsr      FSR0, TC_VALUES_BEGIN      ; base address
      movwf      FSR0L                  ; write WREG to FSR0L

      rcall      TC_DISPLAY_Hlp_CalcPtr_VMode      ; get pointer to value mode entry
      tblrd*                              ; read table entry

      ;; move para value to WREG
      movf      INDF0, W

      ;; devide value by 16 = get value in range 0x00 - 0x07
      rrf      WREG, F            ; WREG/2
      rrf      WREG, F            ; WREG/2
      rrf      WREG, F            ; WREG/2
      rrf      WREG, W            ; WREG/2
      andlw      0x07
      
;; this is not right... :(
      IFSET      WREG, 0x07, movlw 0xFF
      
      call      MIOS_LCD_PrintChar
      
      return

I have trouble coding the condition "if the value is 0x07 use 0xFF instead" for the 8th bar...

Can anyone give me a hand or point me in the right direction with this one?

thanks in advance!

MIOS ROCKS! ;D

Posted

You have to use a temporary register like TMP1 or (better) MIOS_PARAMETER1 ..2 or ..3 (which should be prefered for low-level function) to compare the value by using a xor instruction.

Btw: a 8 bit value can also be divided / 16 by using the swapf instruction

And you can write 0xff to a register by using the setf instruction

And you can left out the return by using "goto" instead of "call" (since the function behind the call will execute the return instruction anyhow)

Example:

        swapf   INDF0, W
        andlw   0x07
        movwf   MIOS_PARAMETER1

        xorlw   0x07 ;; result: zero if value matches
        skpnz
        setf    MIOS_PARAMETER1

        movf    MIOS_PARAMETER1, W
        goto    MIOS_LCD_PrintChar 

Have fun :)

Best Regards, Thorsten.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...