Re: A83: ConvOP1


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

Re: A83: ConvOP1



>From TI:s Utility routines info:
;---------------------------------------------------------
;  _CONVOP1 : CONVERT FP VALUE IN OP1 TO A 2 BYTE HEX    |
;             VALUE.                                     |
;                                                        |
;   INPUT : OP1=FP #                                     |
;   OUTPUT : A=LSB HEX VALUE                             |
;            DE=ENTIRE HEX VALUE                         |
;            ERR IF OP1 EXP>3                            |
;---------------------------------------------------------

You get an error if OP1 is greater then 9,999.

Possible way for doing greater values is that you split OP1 in
two FP numbers: OP1 and OP2 where OP1 contains high byte and OP2 cont. low 
byte.

This is the routine:

;------------------------------------------------------------
;-----OP1 Hex Dividing   Routine By Emir Sakic---------------
;--OP1 divides in OP1 and OP2 where OP1 contains-------------
;--high byte and OP2 cont. low byte--------------------------
;--(in: OP1, out: OP1 high byte, OP2 low byte)---------------
divide:
	call		_op1toop5		;OP1->OP3
	ld		hl,256			;16^2
	call		_setxxxxop2		;256->op2
	call		_fpdiv			;OP1/OP2->OP1
	call		_trunc
	call		_op1toop4
	ld		hl,256			;16^2
	call		_setxxxxop2		;256->op2
	call		_fpmult
	call		_op1toop2
	call		_op5toop1
	call		_fpsub		;Now we have OP1 divided
	call		_op1toop2	;OP1=high byte OP2=low
	call		_op4toop1	;in decimal floating point.
	ret
;------------------------------------------------------------

Then You can display it like this:

(number is in OP1)

	call 		divide
	call		_op1toop4	;save OP1 in OP4
	call		_op2toop5	;save OP2 in OP5
	call		_convop1	;convert fp# OP1 to hex# de
	ld		a,e
	ld		(temp),a

	call		_op2toop1
	call		_convop1
	ld		l,e
	ld		a,(temp)
	ld		h,a

	push		hl
	ld		hl,0000h
	ld		(CURROW),hl
	ld		hl,label
	call		_puts
	pop		hl
	call		_newline
	ld		a,0bh
	ld		(curcol),a
	call		_dispHL
	call 		_getkey

I included the entire program with source code as attachment (for SOS).


>From: Jeremy <jedrake@linknet.kitsap.lib.wa.us>
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: A83: ConvOP1
>Date: Thu, 31 Aug 2000 22:45:12 -0700 (PDT)
>
>
>I have a quick question.  In the following code, only values of R through
>9,999 work.  For R >= 10,000, I get the error "ERR:INVALID DIM."  Any
>ideas about why it does this?  Any possible work-arounds that will allow
>me to load a whole word from a real variable?
>
>Thanks
>Jeremy
>
>call _zerooop1
>ld hl,op1+1
>ld (hl),'R'     ; or any other var
>call _rclvarsym ; op1 / op2 -> value
>call _convop1
>ex   de,hl
>call _disphl
>
>

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.
Warning
Could not process part with given Content-Type: application/x-zip-compressed; name="convop1.zip"