<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 19 Jul 1994 09:24:39 EST
From   : Stephen Quan <quan@...>
Subject: Re: Relative branch in assemble (was SQ's emulators)

> I have a bit of a problem which I think I could really speed up - how can 
> I do relative branches? What I'm doing at the moment (basically) is:
> 
>  load branch distance byte
>  if <branch distance> is less than 128
>  move P back <branch distance>
>  goto end
>  move P forward <branch distance>
>  .end
> 
> Is there a better way of doing this? In the 256^3 speed test this is *by 
> far* where I lose my speed.

My Borland C++ 2.0 compiler gave me the answer.  It converted the
following C fragment into assembly with PC assigned as "SI" and
branch assigned as "DL".

     unsigned short PC     = 0x3000;
     unsigned char  branch = 0xf7;
     PC += (char) branch;


    mov si,12288   ; PC = 0x3000
    mov dl,247     ; branch = 0xf7

    mov al,dl      ; PC += (char) branch;
    cbw
    add si,ax

I must honestly admit I don't really know that much about IBM assembly
code programming, but this Borland C++ 2.0 makes me look like I know
what I am talking about!  :-)  :-)  Seems like you should check out the
"cbw" instruction.  I guess it is convert-byte-to-word which will allow
you to add your signed 8 bit number to your PC quite easily.  I be
interested in knowing how much differents this makes.
-- 
Stephen Quan (quan@...                 ), SysAdmin, Analyst/Programmer.
Centre for Spatial Information Studies, University of Tasmania, Hobart.
GPO BOX 252C, Australia, 7001.  Local Tel: (002) 202898 Fax: (002) 240282
International Callers use +6102 instead of (002).
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>