Another nice math trip for me old man in ASM and inline.
Which program can you use to convert float into 5 bytes for ASM and 5 bytes ih the float?
-----------------------------------
flt_g: .byte $84, $1c, $f5, $c2, $8f ; float 9.81
flt_time: .byte $83, $20, $00, $00, $00 ; float 5.0
flt_two: .byte $82, $00, $00, $00, $00 ; float 2.0
----------------------------------
Thanks.
demo from x16-doc.
Code: Select all
; calculate how far an object has fallen: d = 1/2 * g * t^2.
; we set g = 9.81 m/sec^2, time = 5 sec -> d = 122.625 m.
CHROUT = $ffd2
FOUT = $fe06
FMULTT = $fe21
FDIV = $fe24
CONUPK = $fe5a
MOVFM = $fe63
lda #4
sta $01 ; rom bank 4 (BASIC) contains the fp routines.
lda #<flt_two
ldy #>flt_two
jsr MOVFM
lda #<flt_g
ldy #>flt_g
jsr FDIV ; FACC= g/2
lda #<flt_time
ldy #>flt_time
jsr CONUPK ; ARG = time
jsr FMULTT ; FACC = g/2 * time
lda #<flt_time
ldy #>flt_time
jsr CONUPK ; again ARG = time
jsr FMULTT ; FACC = g/2 * time * time
jsr FOUT ; to string
; print string in AY
sta $02
sty $03
ldy #0
loop:
lda ($02),y
beq done
jsr CHROUT
iny
bne loop
done:
rts
flt_g: .byte $84, $1c, $f5, $c2, $8f ; float 9.81
flt_time: .byte $83, $20, $00, $00, $00 ; float 5.0
flt_two: .byte $82, $00, $00, $00, $00 ; float 2.0
---------------------------------------------
RESTORE ASM
READ Z
FOR P = 0 TO Z-1
READ A
POKE $a000+P,A
NEXT
SYS $a000
ASM:
DATA 73
DATA $A9, $04, $85, $01, $A9, $44, $A0, $A0, $20, $63
DATA $FE, $A9, $3A, $A0, $A0, $20, $24, $FE, $A9, $3F
DATA $A0, $A0, $20, $5A, $FE, $20, $21, $FE, $A9, $3F
DATA $A0, $A0, $20, $5A, $FE, $20, $21, $FE, $20, $06
DATA $FE, $85, $02, $84, $03, $A0, $00, $B1, $02, $F0
DATA $06, $20, $D2, $FF, $C8, $D0, $F6, $60, $84, $1C
DATA $F5, $C2, $8F, $83, $20, $00, $00, $00, $82, $00
DATA $00, $00, $00,
-----------------------------------------------