home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
norge.freeshell.org (192.94.73.8)
/
192.94.73.8.tar
/
192.94.73.8
/
pub
/
computers
/
cpm
/
alphatronic
/
PASCALZ4.ZIP
/
D3
/
CMPCHK.SRC
< prev
next >
Wrap
Text File
|
1999-04-05
|
2KB
|
61 lines
;ROUTINES TO COMPLEMENT AN OPERAND, AND CHECK FOR A ZERO OPERAND
;
NAME CMPCHK
ENTRY .COMPOP,.COMP1,.ZERCHK,.ZERCK1,.FPNEG
INCLUDE FPINIT.SRC
;
; complement an operand
;
.compop: dad d ;and calculate addr of fpacc
.comp1: mvi b,fracln ;process whole mantissa
mov a,m ;get first byte
cma ;complement and...
adi 1 ;..add one
compl: mov m,a ;save present byte
inx h ;bump pointer
mov a,m ;get next byte
cma ;complement and add
aci 0 ;carry
djnz compl ;check for last byte
ret ;yes...done
;
; check number for a zero, or negative zero ( neg. zero can only be
; generated by a floating point operation )
;
;
.zerchk:
dad d ;and calculate address of fpacc
.zerck1:
xra a ;clear flags
mov a,m ;into accumulator
ani 7fh ;check for zero, masking sign bit
dcx h
mvi b,fracln-1 ;process whole mantissa
zchka: ora m ;check next byte
dcx h ;bump pointer
djnz zchka ;any more?
ret ;no, return
;
;negate a f.p. number. if zero, don't negate
;
;
.fpneg:
lxi h,4
dad s ;msb of mantissa
xra a ;clear flags
mov a,m
ani 7fh ;check msb with sign bit masked
dcx h
ora m ;check middle byte
dcx h
ora m ;check low byte
jrz zer ;if number is zero, don't negate
inx h
inx h ;msb of mantissa
mvi a,80h ;set high bit
xra m ;toggle high bit of msb of mantissa
mov m,a ;replace high word of mantissa
zer: ret ;and return