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 - jacobly
Pages: 1 ... 9 10 [11] 12 13 14
151
« on: December 09, 2011, 02:07:28 pm »
Well, InData() works with zero terminated data, and his routine works with G bytes of data and embedded zeros. First of all, {L1+I-1} can be optimized to {I-1+L1}. Other than that, the second one should work fine. Also, the space should be optional. Edit:
152
« on: December 09, 2011, 05:53:34 am »
Not an optimization, but I'm posting this here since more assembly people will read it. Since the Bitmap() command is being replaced with something actually useful, that means the "Fix 8" and "Fix 9" will also need to be replaced. Are there any useful flags (particularly for text) that would be useful to Axe programmers that I haven't already covered with the other fix commands? A couple I can think of are an APD toggle or Lowercase toggle.
I agree with adding the lowercase enable flag, especially if p_GetKeyPause is modified slightly. For example: p_GetKeyPause: ; Change to subroutine .db __GetKeyPauseEnd-1-$ B_CALL(_GetKeyRetOff) res 7,(iy+40) ld h,0 ld l,a cp $fc ret c ld a,($8446) ld h,a ; Edit: something like inc h \ ld l,a might be easier ; since lowercase letters would be consecutive ; or ld hl,($8446) \ ld h,a ret __GetKeyPauseEnd-1-$
153
« on: December 09, 2011, 12:53:34 am »
All drawing operations operate on a 768 byte buffer in memory.
So there *must* be scaling if there are more than one logical unit (coordinate) per physical unit (pixel).
154
« on: December 09, 2011, 12:23:03 am »
Actually BBCBasic uses a 768 byte buffer (the manual is a little ambiguous). It is just that coordinates range from -32768 to 32767 (I think). Commands are just scaled and clipped to that buffer according to some settings. Also, a buffer that big would never even fit in ram and rom combined (2^16 * 2^16 / 2^3 = 2^29 bytes > a theoretical maximum of 2^22 bytes (assuming there were actually 256 separate pages, which is not even close to true)). Edit: Kind of like how TIOS does it, with a ridiculous graphing area, but a small viewing window.
155
« on: December 08, 2011, 08:44:54 pm »
I dont know much about graphs. My attempt failed
And using parser's I think instead of (1/(1+e^X))
-(1/(1+e^X)) makes it go in the right direction even though I have no clue what it really does
Or 1/(1+e^(-X)), the usual form of the logistic function. [wikipedia]Logistic function[/wikipedia]
156
« on: December 08, 2011, 08:35:58 pm »
My first multiplication routine takes 2746 - 4570 cycles, the second takes 1680 - 2880 cycles. Edit: And yes, they are 24*24 bit integer multiplication routines (floating point routines are much more complicated ). As for square root, I should be able to do it using only af bc de hl ix (sp), or af bc de hl ix iy, just like the multiplication. Just give me a couple hours to port it to 48-bit. Edit: uses af bc de hl ix iy (for two bytes of memory) 84 bytes, 9186-9258 cycles ; ahl = sqrt(hldebc) push bc ; ld c,ixl pop ix ; ld b,ixh push de ld c,l ld a,h ld hl,0 ld b,h ld e,l ld d,h ld (iy+asm_Flag1),d ld (iy+asm_Flag2),24 Loop: cp $40 push af sbc hl,de ld a,b sbc a,(iy+asm_Flag1) jr c,Restore ld b,a pop af sub $40 scf jr Skip Restore: pop af adc hl,de or a Skip: rl e rl d rl (iy+asm_Flag1) add ix,ix ex (sp),hl adc hl,hl ex (sp),hl rl c rla adc hl,hl rl b add ix,ix ex (sp),hl adc hl,hl ex (sp),hl rl c rla adc hl,hl rl b dec (iy+asm_Flag2) jr nz,Loop pop hl ld a,(iy+asm_Flag1) ret
uses af bc b' de de' hl hl' ix 74 bytes, 5985-6777 cycles ; dea = sqrt(hldebc) di push bc ; ld c,ixl pop ix ; ld b,ixh ld bc,$40 ld a,l ld l,h ld h,b exx ld de,0 ld l,e ld h,d ld b,24 or a Loop: exx sbc hl,bc exx sbc hl,de jr nc,Skip exx add hl,bc exx adc hl,de Skip: exx ccf rl b exx rl e rl d exx add ix,ix rl e rl d rla adc hl,hl exx adc hl,hl exx add ix,ix rl e rl d rla adc hl,hl exx adc hl,hl djnz Loop exx ld a,b exx ei ret
157
« on: December 07, 2011, 11:05:18 pm »
I do have a 24-bit floating-point multiplication routine Anyway, for normal 24-bit multiplication, it might just barely be possible without using memory, iy, or shadow registers... ; hldebc = hla * cde, a = 0 ld b,0 push hl ld l,b ld h,a ld ix,0 ld a,24 Loop: add ix,ix adc hl,hl ex (sp),hl adc hl,hl ex (sp),hl jr nc,Next add ix,de adc hl,bc jr nc,Next ex (sp),hl inc hl ex (sp),hl Next: dec a jr nz,Loop pop de ex de,hl push ix ; ld c,ixl pop bc ; ld b,ixh
...cool, I was right! saved 2 bytes, 1149 cycles saved by using iy too (and in a way compatible with TIOS, imagine that) ; hldebc = hlc * bde ld (iy+asm_Flag1),b xor a ld ix,0 ld b,24 Loop: add ix,ix rla rl c adc hl,hl jr nc,Next add ix,de adc a,(iy+asm_Flag1) rl c jr nc,Next inc hl Next: djnz Loop ld e,a ld d,c push ix ; ld c,ixl pop bc ; ld b,ixh
158
« on: December 07, 2011, 06:26:21 pm »
100*(2/3)+100*(1/3)*(2/3)+... ∞ 1 n 2 200 2 ∑ (100·(-) ·-) = --- ÷ - = 100 n=0 3 3 3 3
159
« on: December 07, 2011, 06:15:34 pm »
AFAIK, the crystal timers have nothing to do with the clock (they are two different things). The problem is not reading the value of the clock, but the fact that it doesn't fit in an axe variable. Regardless, you can get the value of the clock like this: °AAsm(DB02E6202009AF0604772310FC180FDB477723DB487723DB457723DB4677) and AB would contain the number of seconds since midnight, January 1, 1997, or 0 if the clock is off or the calculator has no clock. °AAsm(DB477723DB487723DB457723DB4677) or this if you know that the calculator has a clock
Also, running ClockOff on my TI84+SE does not turn the clock off (just doesn't display it in the mode menu).
160
« on: December 06, 2011, 01:36:32 am »
p_SDiv: same size, saves an average of 7 cycles 3.5 cycles Edit: oops, abs(hl) isn't always positive (what???) Original p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af bit 7,h jr z,$+8 xor a sub l ld l,a sbc a,a sub h ld h,a bit 7,d jr z,$+8 xor a sub e ld e,a sbc a,a sub d ld d,a call $3F00+sub_Div pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret __SDivEnd:
| Optimized p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af xor d ; a = h jp p,$+9 xor a sub l ld l,a sbc a,a sub h ld h,a ; a = high byte of abs(hl) ; therefore, bit 7 is clear ; xor d ; or works too ; jp p,$+9 ; Edit: doesn't work if hl = $8000 ; because abs($8000) = $8000 bit 7,d jr z,$+8 xor a sub e ld e,a sbc a,a sub d ld d,a call $3F00+sub_Div pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret __SDivEnd:
| Edit: Some more attempts at optimizing. Optimized (speed) +1 byte, avg -19 cycles
p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af xor d ; a = h jp p,$+9 xor a sub l ld l,a sbc a,a sub h ld h,a ld a,d or a jp p,$+9 xor a sub e ld e,a sbc a,a sub d ld d,a ld b,b .db 2 call $3F00+sub_Div pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret __SDivEnd:
p_Div: .db __DivEnd-1-$ ld a,d or a ld b,16 ; ...
| Optimized (size) -4 bytes, avg +37 cycles
p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af ld b,2 __SDivRepeat: ex de,hl xor h jp p,__SDivSkip xor a sub l ld l,a sbc a,a sub h ld h,a __SDivSkip: xor a djnz __SDivRepeat call $3F00+sub_Div pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret __SDivEnd:
| Optimized (lol) -8 bytes, avg +110-4 cycles
p_SDiv: .db __SDivEnd-1-$ ld a,h xor d ld b,2 __SDivRepeat: push af xor d jp p,__SDivSkip xor a sub l ld l,a sbc a,a sub h ld h,a __SDivSkip: dec b ret m ex de,hl ld b,b .db 1 call z,$3F00+sub_Div inc b pop af djnz __SDivRepeat jr __SDivRepeat+2 __SDivEnd:
p_Div: .db __DivEnd-1-$ ld a,d or a ld b,16 ; ...
| Edit: p_SortD: same size, 2*size-5 cycles faster Original p_SortD: .db __SortDEnd-1-$ ld c,l ex de,hl __SortDLoop2: ld b,c push hl jr __SortDJumpIn __SortDLoop1: inc hl cp (hl) jr c,__SortDSkip __SortDJumpIn: ld a,(hl) ld d,h ld e,l __SortDSkip: djnz __SortDLoop1 ld b,(hl) ld (hl),a ld a,b ld (de),a pop hl dec c jr nz,__SortDLoop2 ret __SortDEnd:
| Optimized p_SortD: .db __SortDEnd-1-$ ld c,l ex de,hl __SortDLoop2: ld b,c push hl jr __SortDJumpIn __SortDLoop1: inc hl cp (hl) jr c,__SortDSkip __SortDJumpIn: ld a,(hl) ld d,h ld e,l __SortDSkip: djnz __SortDLoop1 ldi dec hl ld (hl),a pop hl jp pe,__SortDLoop2 ret __SortDEnd:
| Edit: p_Reciprocal: same size, saves avg 2 cycles Original
p_Reciprocal: .db __ReciprocalEnd-1-$ xor a bit 7,h push af jr z,$+7 sub l ld l,a sbc a,a sub h ld h,a ex de,hl ld bc,$1000 ld hl,1 xor a ld b,b .db 10 call $3F00+sub_Div pop af ret z sub l ld l,a sbc a,a sub h ld h,a ret __ReciprocalEnd:
| Optimized avg -2 cycles
p_Reciprocal: .db __ReciprocalEnd-1-$ xor a bit 7,h push af jr z,$+8 sub l ld l,a sbc a,a sub h ld h,a xor a ex de,hl ld bc,$1000 ld hl,1 ld b,b .db 10 call $3F00+sub_Div pop af ret z sub l ld l,a sbc a,a sub h ld h,a ret __ReciprocalEnd:
| Optimized Moar avg -33 cycles
p_Reciprocal: .db __ReciprocalEnd-1-$ xor a bit 7,h push af jr z,$+8 sub l ld l,a sbc a,a sub h ld h,a xor a ex de,hl ld bc,$1001 ld hl,2 ld b,b .db 16 call $3F00+sub_Div pop af ret z sub l ld l,a sbc a,a sub h ld h,a ret __ReciprocalEnd:
| Edit: p_Mod: 2 bytes smaller, 96 cycles faster! Original p_Mod: .db __ModEnd-1-$ ld a,h ld c,l ld hl,0 ld b,16 __ModLoop: scf rl c rla adc hl,hl sbc hl,de jr nc,__ModSkip add hl,de dec c __ModSkip: djnz __ModLoop ret __ModEnd:
| Optimized p_Mod: .db __ModEnd-1-$ ld a,h ld c,l ld hl,0 ld b,16 __ModLoop: sla c rla adc hl,hl sbc hl,de jr nc,__ModSkip add hl,de __ModSkip: djnz __ModLoop ret __ModEnd:
|
161
« on: November 27, 2011, 10:17:04 pm »
Update. Changes: solve() becomes solve()ʳ solve(x) returns a pointer to the floating-point number represented by x. Examples: float{solve(Select("varA"))}➔A float{solve(solve(ᵀ+,Select("varA"),Select("varB")))}➔C
162
« on: November 27, 2011, 08:35:34 pm »
http://en.wikipedia.org/wiki/Truncation limits the number of digits to the right of the decimal point to a certain number. I believe he is asking how many digits you want to truncate to.
16-bit integer would be the easiest to deal with and program (methinks.) Besides, if I want 8.8, I can multiply the float by 256 before converting it.
But what do you want me to do with a floating-point number like 100000?
Wrap around, so it'd be mod 65536
Going by that, I would assume that you want unsigned integers... but what if the floating-point number is negative?
represent it as it would be if it were a negative two's complement 16-bit integer.
ok... but what about -32769?
163
« on: November 27, 2011, 08:14:18 pm »
http://en.wikipedia.org/wiki/Truncation limits the number of digits to the right of the decimal point to a certain number. I believe he is asking how many digits you want to truncate to.
16-bit integer would be the easiest to deal with and program (methinks.) Besides, if I want 8.8, I can multiply the float by 256 before converting it.
But what do you want me to do with a floating-point number like 100000?
Wrap around, so it'd be mod 65536
Going by that, I would assume that you want unsigned integers... but what if the floating-point number is negative?
164
« on: November 27, 2011, 08:02:05 pm »
http://en.wikipedia.org/wiki/Truncation limits the number of digits to the right of the decimal point to a certain number. I believe he is asking how many digits you want to truncate to.
16-bit integer would be the easiest to deal with and program (methinks.) Besides, if I want 8.8, I can multiply the float by 256 before converting it.
But what do you want me to do with a floating-point number like 100000?
165
« on: November 27, 2011, 07:55:56 pm »
Perhaps a floating-point-math Axiom, with a function to store a float to an axevar?
How can a float fit in a single axe var? Unless you want truncation, but then you would have to specify how you want it truncated.
There is only one kind of truncation. It's where you chop off the decimal portion. Or, to put it another way, round towards 0
By how you want it truncated, I mean what do you want it truncated to.
Truncation is a mathematical function. You truncate to a number. To put it in BASIC, iPart()
But what kind of number would you like? An unsigned integer, a signed integer, 256 inflation, some form of signed 256 inflation, bcd, a pointer, a handle...
Pages: 1 ... 9 10 [11] 12 13 14
|