1

One of my concerns right now is making some assembly language subroutines which needs to be called from a C program in order to CountRoutes, FindRoutes or DisplayRoutes on a LCD Screen. For example this is the code in which i have the route addresses saved and for the first subroutine, CountRoutes it should count how many routes do i have in memory before it finds -1 and stops counting.

This is what i've done so far and it's not working. The thing that i need to change is: ignore the .byte null line (jump to the two strings below), verify if you're at the end of the strin (meets 0) and jump again ti'll you find another .word 6 or -1.

            .word  4
            .byte  null
            .asciz "Dee Bridge"
            .asciz ""

            .word  5
            .byte  'x
            .asciz "Echt Terminus"
            .asciz "Express"

            .word  -1              ; route 0xffff terminates the data set

.area   text

_RouteCount::
            pshx
            tfr     d,y         ;
            ldx     #0          ; Clear index
Loop:       ldab    1,y+        ; Fetch next character; inc Y
            bmi     Done        ; If -1 is found, exit loop
            bra     Loop        ; Repeat loop 
            ldx     #1          ; Store no match flag in X
            beq
            bra     Loop
Done:       tfr     Y,D         ; Transfer index in D
            pulx
            rts   
  • one: what kind of assembly language is this? It's not x86, and I don't think it's ARM. Update the tags, please. Two: describe *how* it's not working. Or maybe your block of text with no paragraph breaks has enough description for people that can read that asm. This is why you should tag your question with the tag for whatever architecture this is... – Peter Cordes Dec 03 '15 at 03:00
  • I do apologise.. This si asm for 68hc12. By not working i mean it's not doing anything.And i explained above what changes should be done to make it use..It should skip the next byte ,which is for the address as well and shout go into the strings and seek for 0 and so on untill it reaches the next addresses or -1 to exit loop and return the number of addresses found. void CountingRoutes() { RouteCount(0x3000); routes=RouteCount(); lcd_clear(); sprintf (buf, "%d bus routes",routes); lcd_putxy(0, 0, buf); sprintf (buf, "Any key for menu"); lcd_putxy(3, 0, buf); } – Alexandru Tudoran Dec 03 '15 at 04:07
  • You can edit your question to modify tags and make other changes. (click "edit" under the question). There is already a 68hc12 tag. (only 20 other questions on it, though, but at least you'll increase the chance of the right person seeing your question.) Like I said, maybe your question already makes sense to people that know 68ch12, just not to me since I don't. :P I'd suggest splitting up that big opening paragraph into a couple separate ones, though. – Peter Cordes Dec 03 '15 at 04:16

0 Answers0