[A83] Re: ugly symbols with an directory list


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

[A83] Re: ugly symbols with an directory list



I tried to use:

// on top:
#define blieb 8400h


ld (blieb),a
ld    a,(skipcounter) ;new
dec   a                ;new ;is skipcounter=1?
jr    nz,badprog       ;new ;if no, skip this program
ld a,(blieb)

omg! it doesn't work! My program doesn't crash, but i can't see whethere a
prgm is protected or not. What am I going to do now? :(

-----Oorspronkelijk bericht-----
Van: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org]Namens Patai Gergely
Verzonden: zondag 7 september 2003 22:00
Aan: Assembly-83 list
Onderwerp: [A83] Re: ugly symbols with an directory list


> into:
>
> push af
> ld    a,(skipcounter)
> dec   a                ;is skipcounter=1?
> jr    nz,badprog       ;if no, skip this program
> pop af
>
> Now, I can see if a prgm is protected or not, but now, the program seems
> to
> make my calculator a bit messy, it seems to crash, and the program run
> strange after the first run. So how can I fix this? I think it has
> something
> to do with push af and pop af, because I haven't use the F register.
>
Ask yourself the question what happens if the jump is actually taken, and
when pop af will be executed in that case... To avoid corrupting the
stack, you could as well put the accumulator away into a memory variable
or an unused register:

ld (tempvar),a
ld a,(skipcounter)
dec a ; is skipcounter=1?
ld a,(tempvar) ; (you can do this, because it doesn't affect the flags)
jr nz,badprog ; if no, skip this program

An unused 8-bit register would be better though.

PG

--
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again






Follow-Ups: References: