QDOS Internals

Anything you never knew you wanted to know about the Sinclair QL.

User Tools

Site Tools


CN_FTOD.../CV_FPDEC... - Vectors $F0 to $FE

These vectors convert a value to which (A1,A6.L) points to ASCII characters in a buffer to which (A0,A6.L) points.

List of Vectors

CN_FTODCV_FPDEC$F0Convert Floating Point to Decimal
CN_ITODCV_IWDEC$F2Convert word to Decimal
CN_ITOBBCV_IBBIN$F4Convert byte to Binary
CN_ITOBWCV_IWBIN$F6Convert word to Binary
CN_ITOBLCV_ILBIN$F8Convert long to Binary
CN_ITOHBCV_IBHEX$FAConvert byte to Hexadecimal
CN_ITOHWCV_IWHEX$FCConvert word to Hexadecimal
CN_ITOHLCV_ILHEX$FEConvert long to Hexadecimal


Call ParametersReturn Parameters
D0.LUnused D0.LCorrupted.
D1.LUnused D1.LCorrupted or length of answer
D2.LUnused D2.LCorrupted.
D3.LUnused D3.LCorrupted.
A0.LPointer to buffer A0.LUpdated.
A1.LPointer to value A1.LUpdated.
A2.LUnused A2.LCorrupted.
A3.LUnused A3.LCorrupted.


No errors are returned by this vector call.


  • All registers not shown above are not used on entry and are preserved on exit.
  • On return D1.L contains the length of the answer for CN_FTOD/CV_FPDEC and CN_ITOD/CV_IWDEC but is otherwise corrupted.
  • On entry (A0,A6.L) points to a buffer to contain the ASCII answer. On return A0 is increased by the number of characters in the answer.
  • On entry (A1,A6.L) points to the value to be converted. On return A1 is increased by 1, 2, 4 or 6 depending on the length of the value (byte, word, long word or floating point).
  • The translation to ASCII performed by CN_FTOD/CV_FPDEC may not be obvious. Integers in floating point form become simply the ASCII integers. Thus 25 and -200 will be these two or four byte strings. However, more general floating point numbers may be shown in floating point format or, if possible, simply as decimal numbers. To illustrate this are three examples.
    • $0100146208E1 becomes 5.785646E-541 - length 13
    • $0800146208E1 becomes .1592418 - length 8
    • $0820146208E1 becomes 6.839382E8 - length 10
  • If too little space is allocated for the answers produced by CN_FTOD/CV_FPDEC this may cause a crash. If you expect all floating point numbers translated by CN_FTOD/CV_FPDEC to be positive integers less than 100 a two byte answer space should suffice. However, an error in the floating point form may cause the production of up to 13 bytes. One should beware of this.


The example below shows how to convert a long word to hexadecimal.

; A6 points to data space.
; num(A6) points to the long word to be converted.
; buf(A6) points to a buffer to contain the answer.

num     equ     #26             ; Allows a stack of 30 bytes
buf     equ     #30             ; The buffer follows the value

Conv    lea     num,a1          ; Point to long word relative to A6.
        lea     buf,a0          ; Point to buffer relative to A6.
        movea.w CN_ITOHL,a2     ; Address of vector.
	jsr	(a2)		; Make the call

; Now the value is at buf(A6).
; A0 is buf + 8.
; A1 is num + 4.
qdosmsq/vectors/fpdec.txt · Last modified: 2014/06/08 14:54 by george.gwilt