The PSION Organiser II Homepage
Forum Home Forum Home Help Help Search Search Members Members Login Login Register Register

Welcome, Guest. Please Login or Register.
Why register?
   The Psion Organiser II Forum
   User Forum
   Help
(Moderator: Mikesan)
   ML Programming
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: ML Programming  (Read 1056 times)
POISN
active Member




   


Posts: 48
ML Programming
« on: May 14th, 2003, 8:19am »
Quote Quote Modify Modify

How do you test the parity of a byte in machine language?
Zac Schroff
Power Member




   
WWW

Posts: 81
Re: ML Programming
« Reply #1 on: May 27th, 2003, 10:03pm »
Quote Quote Modify Modify

on May 14th, 2003, 8:19am, POISN wrote:
How do you test the parity of a byte in machine language?

 
Unfortunately, the HD6303 does not have the 'parity' bit in the flags register, so you need to count it yourself.  Code segment included (plus example of how to call it at the top).
 

         LDB   <parity_source>
         JSR   bitcnt:
 

 

;
; Bit count : counts number of bits in B register which
; are set on.
;
; If you wanted parity, you only need the lowest bit of
; the A register on return : use it as-is for even parity,
; invert it for odd.
;
;  in : B = byte whose bits are to be counted
; out : A = number of bits which were on in B
;
bitcnt:  PSH   B
         PSHX
         LDX   #$0008
         LDA   #$00
bitcnt1: LSR   B
         ADC   A,#$00
         DEX
         BNE   bitcnt1:
         PULX
         PUL   B
         RTS
 
« Last Edit: May 27th, 2003, 10:06pm by Zac Schroff »

Tact is for those who are not witty enough to be sarcastic.
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

The Psion Organiser II Forum » Powered by YaBB 1 Gold - SP 1.1!
YaBB 2000-2002,
Xnull. All Rights Reserved.
top