Re: A86: Line(x1,y1,x2,y2,0 with ASM?


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

Re: A86: Line(x1,y1,x2,y2,0 with ASM?




>>In the basic part you make 5 vars,
>>say X1, Y1, X2, Y2 and COLOR. Then
>>you do Asm(line or whatever you want
>>to call the asm part and it simply
>>loads the values from X1, Y1, X2, Y2
>>and C into b, c, d, e, and h and calls
>>_ILine.
>I don't  know about you, but I don't want to have all that extra code 
>in my programs.  
<snip>
>Obviously the information needs to be stored somewhere for an assembly 
>program to find.  I suggest storing all the information to a single
>variable, Ans.

I tried doing this, but for some reason ILine dosen't seem to do
anything.  I know the program isn't terminating early, everything seems
to work, only nothing appears.  The program gets the data out of Ans in
the form of a list.  Here's the program I'm using for a test:

DispG
{1,1,5,5,1}
Asm(line)
Pause

And here's the ASM code, it's very sloppy and I haven't even thought
about optomizing yet.  Also, be careful, if Ans somehow ends up with
non-integer elements, I have no clue what might happen.

#include "asm86.h"
#include "ti86asm.inc"
#include "ti86math.inc"
#include "ti86ops.inc"
#include "ti86abs.inc"

.org _asm_exec_ram

_delvar 		equ	475Fh
_FINDSYM	equ	46CBh
_convop1		equ	5577h 

main:
	call	_ZEROOP1
	ld	hl,ans			; Source = ans
	ld	de,_OP1+1		; Dest = OP1+1
	ld	b,0
	ld	c,4			; copy 4 bytes
	ldir				; execute the copy
	call	_FINDSYM		; carry flag set if var
dosen't exist
	jr	c,exit			; if so, quit without
doing anything
	and	1fh			; mask out flags, a =
vartype
	cp	04h			; do we have a real list?
	jr	nz,exit			; if not, quit without
doing anything
	ld	a,b			; copy abs address of list
from bde to ahl
	ld	h,d
	ld	l,e
	call	_load_ram_ahl		; loads the correct page
and sets hl as pointer to list
	ld	a,(hl)			; a = length of list
	cp	5			; do we have 5 elements?
	jr	nz,exit			; if not, quit without
doing anything
	inc	hl
	inc	hl
	inc	hl			; move to start of first
element
	call	getelement		; get x1
	ld	b,e			; store it to b
	call	getelement		; get y1
	ld	c,e			; store it to c
	call	getelement		; get x2
	ld	d,e			; store it to d
	call	getelement		; get y2, already in e
	push 	de			; store de on stack
	call	getelement		; get color
	ld	h,e			; store it to h
	pop	de			; restore de from stack
	call	_ILine			; draw the line
	ret

getelement:
	push de				; store de on stack
	rst 20h				; copy 10 bytes starting
at hl to OP1
	ld	d,10d			; de = 10
	ld	e,0
	add	hl,de			; hl = hl + de(10)
	pop	de			; restore de from stack
	call	_convop1			; e = What was
pointed to by hl in
					; OP format
	ret

exit:
	call	_getkey			; wait for keypress
(debugging)
	ret				; return to system

ans:
	.db		03h,"Ans"

.end

Anyone have any ideas?  I put the getkey in there to let me know if the
program exited abnormally, the calc would pause for a keypress twice, but
only once if it exited normally.  (1 pause in asm, 1 in basic)

---
Andy Johnson
I think therefore I am, I think


References: