Re: LZ: Problem with code


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

Re: LZ: Problem with code



Carl Wang wrote:
> 
> Hi! Here's a program I'm having a lot of trouble with.  If you can help,
> please do, I'm eager to get this program out not long before school
> starts.  Thanks a lot!!
 


OK, I'm assuming you're not an expeirienced ASM programmer (please
correct me if I'm wrong!), so I am going to try ro explain this as
thouroughly as I can:


> 
> HEALTH = $80DF                  ;Location of HEALTH value


When you use text variables, you are asigning a variable (health) a
value.  The value i not really a location, but it can be used as such
(like in your program).  
 
> LOSE:
>         LD BC,$0101             ;This is supposed to show the value of
>         LD ($800C),BC           ;HEALTH but it doesn't want to.
>         LD HL,HEALTH            ;It says 32991 every time.


It says 32991 every time because that is how you programmed it.  Look,
remember from the text variables that the VALUE of the variable HEALTH
is $80DF, or in decimal 32991.  By now, thing should be going "click" in
your head, as you see, what you are doing in your program is loading the
number 32991 ($80DF in hex) into hl, then displaying it.  Now, text
variables are used for the ease of the programmer, then interpreted by
the compiler.  So what you are doing is "LD HL,32991", which is not what
you want to do.  what you *want* to do is:


LD    HL, (HEALTH)


which will load the value stored at the location HEALTH (or the location
$80DF) in the memory.  This should fix your problem.


>         ROM_CALL(D_HL_DECI)
>         LD A,HEALTH             ;I'm trying to find the value of HEALTH and
>         CP 00                   ;go to the place where the apropriate


<pre>
-- 
; Max Mansour  // mail : mmansour@gis.net
;             // irc : Justarius
; 
; The Presidents -> http://www.gis.net/~mmansour/
; HP OmniGo 100  -> http://www.gis.net/~mmansour/omnigo/omnigo.html
; ZShell         -> http://www.gis.net/~mmansour/zshell/zshell.html


.end
</pre>


References: