<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 02 Aug 1994 09:11:50 EST
From   : Stephen Quan <quan@...>
Subject: Assembly register usage.

Chris Rae has :

> >  AL = used for arithmetic
> >  AH = carry and zero flags (from PC flags)
> >  BL = next instruction opcode
> >  BH = unused (needs to be zero for opcode lookup table)
> >  CL = A
> >  CH = X
> >  DL = BBC flags
> >  DH = Y
> >  DS = BBC memory segment
> >  SI = PC
> >  ES = unused
> >  DI = BBC stack pointer

I see, you are using AX for temporary work space and storing the
status register.  This make full use of the SAHF and LAHF instructions.

Alan Hart writes :

> For what it's worth, you will need some data other than this stuff - and you
> will have to store it in the PC's RAM. Thus you will almost certainly need
> another segment (ES). Unless you store stuff in the Code Segment.

In a way, I kinda agree with Alan.  This is because if you decided
that ES points to a 64K page frame, then you can use ES:SI to refer
to it.  Having done it that way, a single LODSB will retrieve the
next opcode and autoincrement SI, ie. you get two statements for
the price of 1!!!!

Because LODSB directly uses AL (or LODW and AX), this conflicts
with your (CR's) usage of SAHF and LAHF uses.  Well, it's one method
or the other.

In my case, I have used my alternative method of not storing the
status register anywhere (well at least not needing to store NVZC
stored anywhere).  This method doesn't give much of a performance
improvement in the C version of my emulator as there are other
overheads introduced, but in the assembly version this technique
just rocks!!

Perhaps Chris, you could have :

   ES : point to 64K beeb memory
   SI : beeb PC
   AH : most of time zero (for opcode), volatile variable
   AL : next opcode
   BH : status register

for your fetch, you just do a (make sure direction flag is correct)

   LODSB
   MOV   DI,AX
   ADD   DI,AX
   JMP   @somewhere[DI]

for something such as DEX (assume BL = X)

   DEC   X
   SAHF
   MOV   BH,AH
   MOV   AH,0

Then you'll have the best of both worlds.
-- 
Stephen Quan
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>