Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xeda112358

Pages: 1 ... 108 109 [110] 111 112 ... 317
1636
ASM / Arbitrary Precision Multiplication (z80)
« on: September 17, 2012, 09:22:38 am »
In case anybody else wanted some arbitrary precision multiplication, here is a routine :)
Code: [Select]
;===============================================================
AP_Mul_AP:
;===============================================================
;Inputs:
;     HL points to the first number (little-endian, size prefix 2 bytes)
;     DE points to the second number (little-endian, size prefix 2 bytes)
;     BC points to the output location
;Output:
;     The RAM at HL contains the product (little-endian with
;     size prefix). Size is adjusted so there won't be zeroes
;     at the end.
;Notes:
;     This will erase bytes of RAM at (HL) equal to the
;     size of the first number plus the size of the second.
;     So if you use saveSScreen:
;         First number uses 2+M bytes
;        Second number uses 2+N bytes
;        Output number uses 2+M+N bytes
;     At most, 2+N+2+M+2+M+N=768.
;        2+N+2+M+2+M+N = 768
;              6+2M+2N = 768
;               2(M+N) = 762
;                  M+N = 381
;     In otherwords, you can multiply two, 190 byte numbers. In
;     Decimal, this comes out to roughly two 457 digit numbers
;     to get up to 915 digit number. It requires 14952 bytes of
;     RAM to use two numbers >9000 digits
;===============================================================
     di
;First, we get the size
     ld (output),bc   ;4 bytes, save the output location
     ld c,(hl)
     inc hl
     ld b,(hl)
     inc hl
     ld (Num1Loc),hl  ;3 bytes, save the location of the first number
     ld (Num1Size),bc ;4 bytes, save the size
     ex de,hl
     ld e,(hl)
     inc hl
     ld d,(hl)
     add hl,de
     ld (Num2Loc),hl  ;3 bytes, save the location
     ld (Num2Size),de ;4 bytes, save the size
     ex de,hl
     add hl,bc        ;size of the output RAM
;Now we clear out the bytes for the output
     ld b,h
     ld c,l
     ld hl,(output)
     ld (hl),c
     inc hl
     ld (hl),b
     inc hl
     ld (output),hl
     ld (Num3Size),bc
     xor a
       ld (hl),a
       cpi
       jp pe,$-3
;Now we start multiplying stuff
;We need to do:
;     hl=(Num2Loc)
;     de=(Num1Loc)
;     ix=(output)
;     bc=(Num2Size)
;(hl)_Times_(de)_To_(ix)
   exx
   ld bc,(Num3Size)
   exx
   ld bc,(Num2Size)
;   ld hl,(Num2Loc)
   ex de,hl
Loop1:
   push bc
   ld b,8
Loop2:
;===============================================================
;   rl (output)
;===============================================================
     exx
     ld hl,(output)
     ld d,b
     ld e,c
     dec de
     inc d
     inc e
     or a
       rl (hl)
       inc hl
       dec e
       jr nz,$-4
       dec d
       jr nz,$-7
     exx
;===============================================================


   rlc (hl)
   jr nc,NoAdd
;add (output),(Num1Loc)
     exx
     ld de,(Num1Loc)
     push bc
     ld bc,(Num1Size)
     dec bc
     inc c
     inc b
     ld hl,(output)
     or a
AddLoop:
       ld a,(de)
       adc a,(hl)
       ld (hl),a
       inc hl
       inc de
       dec c
       jr nz,AddLoop
       dec b
       jr nz,AddLoop
       jr nc,$+3
       inc (hl)
     pop bc
     exx
NoAdd:
   djnz Loop2
   pop bc
   cpd
   jp pe,Loop1
   ld hl,(output)
   ld bc,(Num3Size)
   add hl,bc
   dec hl
   inc bc
   xor a
     cpd
     jp po,$+5
     jr z,$-5
   ld hl,(output)
   dec hl
   ld (hl),b
   dec hl
   ld (hl),c
   ret
I used this in a test app and wrote a routine to multiply two base 10 integers in Str1 and Str2 respectively (I had to convert the base 10 string to hex data, then multiply, then convert back to base 10). I then used this routine in BatLib to make the routine for base conversion that handles large numbers (hundreds of digits). Feel free to supply other routines or optimisations, too! (I know some of you will find some :P)

1637
Grammer / Re: Grammer 2-The APP
« on: September 17, 2012, 07:47:33 am »
If Grammer gets ported to the TI-86, 4-level grayscale has to come as a standard drawing mode XD Same for the 89 and 92...

1638
BatLib / Re: BatLib
« on: September 14, 2012, 09:40:33 am »
Hmm, I did test it and the issue is similar (shading is on the other side). Also, I forgot to release a fixed version for a bug I found a few weeks ago :/ If you have no apps with GroupHook enabled, running BatLib will crash your calc. The fix was simple, but I have to remember to put it on my flashdrive before I come to campus D:

I still don't know why the shading occurs, though, but I suspect it has to do with GroupHook

EDIT: I am pretty sure this is the problem because a certain register isn't preserved (A). When I manually preserved it, it worked fine.

1639
Grammer / Re: Grammer 2-The APP
« on: September 14, 2012, 09:28:54 am »
If I made a program version, I think it would be around 5000 bytes and be a port of the Grammer 1. The port would probably be smaller and faster than Grammer 1, too, because I optimised a lot of that code in Grammer 2 :D

1640
Grammer / Re: Grammer 2-The APP
« on: September 12, 2012, 09:03:28 am »
I am not sure if I will have the time for the TI-82/83 port. I would like to finish or at least start it this semester or next winter.

As for Grammer 3, I am not starting it yet (I won't start for another year, probably).

The french tutorial is going to be so helpful, thank you for making it!

EDIT: Wow, I just glanced at it and it looks amazing!

1641
BatLib / Re: BatLib
« on: September 12, 2012, 08:00:46 am »
Wow, that is weird. I am going to need to figure out how it is doing that. It doesn't seem to be setting flags and I am pretty sure all the RAM that I use is decently documented. Have you tried it with the most recent BatLib? (Not BatLibG) I am at school right now and I cannot test on this computer (no USB ports work so I cannot even use Wabbit on my flash drive)

I stopped BatLibG in the last update since the new code for GroupHook was fast enough for my liking. (I just added in GroupHook to the normal BatLib)

1642
TI Z80 / Re: CopyProg
« on: September 11, 2012, 12:12:05 pm »
Thanks, that has been a long time. I feel old o.o I think it was a useful update though, and I finally remembered to upload the new version to TICalc (which had only the original version XD)

1643
TI Z80 / Re: CopyProg
« on: September 09, 2012, 05:42:41 pm »
Woo, a small (ish) update is here. Copyprog is now 707 bytes, but I added in the ability to Archive and Unarchive variables (thanks pocketpc for messaging me to do this!) and I also fixed the little GetName bug that made Str1, GDB1, pic1 and other "<<OSvartype>>1" variables from not appearing correctly.

1644
TI Z80 / Re: ORG: online Z80 IDE and assembler
« on: September 09, 2012, 04:16:27 pm »
The internet doesn't work yet at home. We are in an apartment that is supposed to have wireless, but the landlords have had issues. We are waiting to be all wired up, now XD

1645
TI Z80 / Re: ORG: online Z80 IDE and assembler
« on: September 09, 2012, 02:48:13 pm »
Yeah, I think line numbers should be fine :D Thanks!

EDIT: I very much enjoy that I can copy my code from my home computer to a flash drive and then get on a public computer when I am in town and continue programming. :) This is a great project, Deep Thought!

1646
TI Z80 / Re: ORG: online Z80 IDE and assembler
« on: September 07, 2012, 04:36:12 pm »
Hmm, I make a habit of using \ for repetitive code. For example:
Code: [Select]
rlca \ rlca \ rlca \ rlca
However, ORG seems to have an issue with it .__. Is it possible to modify it to use \ as a newline, or will it be a pain?

EDIT: Also, cool autocompletion!

1647
ASM / Re: ASM Command of the Week
« on: September 07, 2012, 04:14:24 pm »
Yes, that is what I would try to do, if I can manage it.

1648
ASM / Re: ASM Command of the Week
« on: September 07, 2012, 09:07:38 am »
Okay, I will have to experiment a little with that, then. I don't care to use a standard USB protocol, anyways.

1649
TI Z80 / Re: The Impossible Game
« on: September 07, 2012, 09:04:32 am »
Yes, porting it should be possible, if anybody was up to the task.

1650
ASM / Re: ASM Command of the Week
« on: September 05, 2012, 12:33:48 pm »
Hmm, so if I am reading your post properly, the first code sends 8 bytes to port $A0, and the second writes all the bytes being received, to HL, and then returns the number of bytes that were received? Is USB control that easy?

Pages: 1 ... 108 109 [110] 111 112 ... 317