A83: Will this work?


[Prev][Next][Index][Thread]

A83: Will this work?




I am kind of new at assembly and wrote this yesterday and today to search for
programs (protected or not) starting with the charachters E and B. The ones
that match are stored in variables pointed to by TEMP1 (rom page, offset, and
ti-os name) If there is an easier way to do this, please tell me.

I know it is inefficient and not commented well, but if someone with more
experence would look over this, I would be very thankful. (This is for a book
reading program for the 83+, but not the 83 (too limited amount of ram, and I
don't have one), however when I am done if someone wants to port it, I will
try to help)

Sorry about the long message,
James Lancaster

LOAD_EB_PROGRAMS:
        ld b,0
        ld (BOOKNUMBER),b
        ld bc,86B9h     ;38 bytes less than where it will start as
        ld (TEMP1),bc   ;LOAD_RECORD adds 38 to it
        ld hl,progPtr
        jp RECORD_TESTS
 
RESET_TO_START_2:       ;I know these are inefficient as hell
        inc hl
RESET_TO_START_1:
        inc hl
        inc hl
        inc hl
        inc hl
        inc hl
        inc hl
        inc hl
NEXT_RECORD:
        dec hl
        dec hl
        dec hl
        dec hl
        dec hl
        dec hl
        ld a,(hl)
AGAIN:
        dec a
        dec hl
        cp 0
        jp nz,AGAIN
 
 
RECORD_TESTS:
        ld bc,(Ptemp)
        ld a,h
        cp b
        jp nz,NOT_DONE_WITH_SEARCH
        ld a,l
        cp c                                     
        jp nz,NOT_DONE_WITH_SEARCH
        ret                             ;done searching
 
NOT_DONE_WITH_SEARCH:
        ld a,(hl)
        and 7
        bit 3,a
        jp z,NEXT_RECORD
        cp 4
        jp z,NEXT_RECORD
        cp 7
        jp z,NEXT_RECORD
        ;this record is a (un)protected program either works
        dec hl
        dec hl
        dec hl
        dec hl
        dec hl
        dec hl
        dec hl ;now at first char of name
        ld a,(hl)
        cp 69   ;is a E in other words
        jp z,RESET_TO_START_1
        dec hl
        ld a,(hl)
        cp 66   ;is a B in other words
        jp z,RESET_TO_START_2
        inc hl
        inc hl ;now at # of chars in title byte
LOAD_RECORD:
        inc hl
        inc hl
        inc hl
        ld ix,(TEMP1)
        ld e,38
        ld d,0
        add ix,de
        ld (TEMP1),ix ;each record takes up 38 bytes, so this goes to the
next record
        ld a,(hl)
        ld (ix+9),a
        inc hl
        ld a,(hl)
        ld (ix+11),a
        inc hl
        ld a,(hl)
        ld (ix+10),a
        dec hl
        dec hl
        dec hl
        ld a,(hl)
        ld c,a
RECORD_NAME:            ;loop for number of chars
        dec hl
        ld b,(hl)
        dec a
        ld (IX),b
        cp 0
        jp nz,RECORD_NAME
        ;name, flash rom page, offset on that page should all be in ram 
GO_TO_NEXT_RECORD:
        inc hl  ;it was on last byte of name, search again
        jp RECORD_TESTS
                                      



Follow-Ups: