[A83] Re: Conditional bcall()ing


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

[A83] Re: Conditional bcall()ing




Right, my fault about lables.
jr 3 gave me error with $9327 as start address, thanx for clearing it.

Anyway to conclude:
#define bcall_z(addr) jr nz,$+5 \ rst 28h \ .dw addr
:)


>From: Tijl Coosemans <tijl.coosemans@mail.be>
>
>Lets clear out some confusion ;-)
>
>If you assemble this:
>
>    jr label
>    [..]
>label:
>    [..]
>
>TASM will convert 'label' to an address which depends on the '.org' 
>directive. Then TASM computes the number of bytes between the address of 
>the byte after the 'jr' instruction and the calculated address of 'label'.
>
>If one assembles the following:
>
>    jr 3
>
>TASM obviously doesn't have to calculate a label address. It just takes the 
>address 0003h and calculates the number of bytes between the address of the 
>byte after the 'jr' instruction and 0003h.
>
>Then something like this:
>
>    jr $+3
>
>TASM interprets $ as a label. The following is exactly the same:
>
>label:
>    jr label+3
>
>So TASM will calculate the number of bytes between the address of the byte 
>after the 'jr' instruction and the address calculated from label+3.
>
>Some examples:
>-----
>.org 0000h
>    jr 3   ; byte after 'jr' is 0002h: 0003h-0002h=0001h -> hex 1801
>.end
>-----
>.org 9327h
>    jr 3   ; byte after 'jr' is 9329h: 0003h-9329h=6CDAh -> error
>.end
>-----
>.org 9327h
>    jr $+3   ; byte after 'jr' is 9329h: 9327h+0003h-9329h=0001h -> hex 
>1801
>.end
>-----
>
>Hope this helps!
>
>Tijl Coosemans
>
>
> > ----------------------------------------
> > From: Olle Hedman <alh@home.se>
> > Sent: Mon Oct 29 17:17:48 GMT+01:00 2001
> > To: <assembly-83@lists.ticalc.org>
> > Subject: [A83] Re: Conditional bcall()ing
> >
> >
> >
> > At 15:42 2001-10-29, you wrote:
> > >Yes, that's right, just a small correction:
> > >You can't write "jr nz,3" nor "jr 3" if you are going to compile with 
>TASM
> > >because TASM will then look for a label called "3".
> > >That's why you must use operator $ ("jr nz,$+5" in our example) when
> > >assembling with TASM.
> > >If you are going to assemble by hand then you could write hex: 2003)
> >
> > Not true, labels can't start with a number so TASM knows this is not a
> > label, but a number.
> > But my statement wasn't true either I just found out.
> > you _can_ write "jr 3"  but it will assemble to "1801" and not "1803", 
>so
> > tasm assumes you count from the current instruction even with this 
>format,
> > so you have to write "jr 5" even with this.
> > Messy :)
> >
> > ///Olle
> >
> >
> >
>
>-----------------------------------------------------
>Mail.be, Free WebMail and Virtual Office
>http://www.mail.be
>
>
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





Follow-Ups: