A83: Matrices
[Prev][Next][Index][Thread]
A83: Matrices
here are my 2 matrix programs. the first one creates a matrix and stores
a floating point number to each element. the second one displays all the
elements in a matrix. once again, enjoy! =)
zmatrix.z80:
.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
_creatermat .equ 446Ah
rmatobj .equ 02h
.org 9327h
call _zerooop1 ; clear op1
ld hl,op1 ; copy var name for matrix [A] into op1
ld (hl),rmatobj ;
inc hl ;
ld (hl),tvarmat ;
inc hl ;
ld (hl),tmata ;
call _chkfindsym ; look it up
call nc,_delvar ; if it is there delete it
ld hl,$0102 ; 1 by 1
call _creatermat ; create it
; store to elements
;
; takes less space than _puttol because you
; copy the data directly to the element
; instead of to op1, then to the element
push de ; save matrix address
ld bc,$0101 ; element 1
call _adrmele ; calculate element address
ex de,hl ; de -> element address
ld hl,element1 ; hl -> num
ld bc,9 ; 9 bytes
ldir ; copy num to element
pop de ; restore matrix address
ld bc,$0102 ; element 2
call _adrmele ; calculate element address
ex de,hl ; de -> element address
ld hl,element2 ; hl -> num
ld bc,9 ; 9 bytes
ldir ; copy num to element
ret
element1:
.db $00,$80,$75,$00,$00,$00,$00,$00,$00 ; 7.5
element2:
.db $80,$82,$73,$45,$67,$23,$89,$00,$00 ; -734.5672389
; notes:
;
; 1) these are the matrix names
;
; [A] rmatobj,tvarmat,tmata
; [B] rmatobj,tvarmat,tmatb
; [C] rmatobj,tvarmat,tmatc
; [D] rmatobj,tvarmat,tmatd
; [E] rmatobj,tvarmat,tmate
; [F] rmatobj,tvarmat,tmatf
; [G] rmatobj,tvarmat,tmatg
; [H] rmatobj,tvarmat,tmath
; [I] rmatobj,tvarmat,tmati
; [J] rmatobj,tvarmat,tmatj
.end
END
------------------------------------------------------------------------
zmatrix.z80:
.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
_errundefined .equ 467Bh
rmatobj .equ 02h
.org 9327h
call _zerooop1 ; clear op1
ld hl,op1 ; copy var name for matrix [A] into op1
ld (hl),rmatobj ;
inc hl ;
ld (hl),tvarmat ;
inc hl ;
ld (hl),tmata ;
call _chkfindsym ; look it up
jp c,_errundefined ; error if not found
push de ; de -> matrix address
pop hl ;
call _ldhlind ; hl -> matrix size
ld bc,$0101 ; bc -> element number
rowl:
push hl ; store count
push bc ; store element num
coll:
push hl ; store count
push bc ; store element num
push de ; store matrix address
call _getmtoop1 ; get element to op1
ld a,16 ; format number for display
call _formreal ;
ld hl,16 ;
sbc hl,bc ;
ld a,l ;
ld (curcol),a ;
ld hl,op3 ;
call _puts ; display it
pop de ; restore matrix address
pop bc ; restore element num
inc c ; increment column
pop hl ; store count
dec l ; decrement column count
ld a,l ; see if coulmn count is at 0
or a ;
jr nz,coll ;
pop bc ; restore element num
inc b ; increment row
pop hl ; restore count
dec h ; decrement row count
ld a,h ; see if row count is at 0
or a ;
jr nz,rowl ;
ret
; notes:
;
; 1) these are the matrix names
;
; [A] rmatobj,tvarmat,tmata
; [B] rmatobj,tvarmat,tmatb
; [C] rmatobj,tvarmat,tmatc
; [D] rmatobj,tvarmat,tmatd
; [E] rmatobj,tvarmat,tmate
; [F] rmatobj,tvarmat,tmatf
; [G] rmatobj,tvarmat,tmatg
; [H] rmatobj,tvarmat,tmath
; [I] rmatobj,tvarmat,tmati
; [J] rmatobj,tvarmat,tmatj
.end
END
References: