I'd suggest at least making an effort to learn it. It's well documented, rather straightforward, and very fast; however, it takes patience and practice to learn.
I got started on the TI-82 with the now very dated TI-82 Assembly Corner tutorial, but TI-83 Plus Assembly in 28 Days (which is currently being updated) is probably the best way to go for anything remotely modern.
For me the most amazing part in learning ASM was starting to understand on a rather low level how computers actually work, i personally found that extremely rewarding
So...I'd like to get ya'lls take on ASM...Well, Do you already know how girls work? If you do, you can learn ASM next, if not, look around for a higher level approach.
I've always been interested in learning it, but it seems so foreign of a computer language...is it worth the trouble to learn? Should I stick with axe?
What's the ups and downs? Is there much difference between ti 83 & 84 ASM?
For all you ASM gurus!
Well, Do you already know how girls work?
Sometimes it looks ugly down there, but for others is just a wonderful discovery. See, it all depends. I'd say give it a go, oh and BTW, ASM changes with the cpu, hehe. :P
Quote from: SpiroH on February 25, 2017, 10:02:20 am
Well, Do you already know how girls work?
Quote from: SpiroH on February 25, 2017, 10:02:20 am
Sometimes it looks ugly down there, but for others is just a wonderful discovery. See, it all depends. I'd say give it a go, oh and BTW, ASM changes with the cpu, hehe. :P
<<<_<<<
;C is our "top" number.
;E is our "bottom" number.
;A will be our "accumulator"
ld a,0
rrc e ;this rotates register 'e' right, putting the bottom bit as "carry" [out of the register].
jr nc,checkbit1 ;nc == not carry. If "carry" out was zero, skip this step.
add a,c ;if carry out was 1, then add to our accumulator.
checkbit1:
sla c ;finally, shift our "top number" to the left in case we need to add this to the accumulator, too. Then [REPEAT] 7 more times.
rrc e
jr nc,checkbit2
add a,c
checkbit2:
sla c
rrc e
jr nc,checkbit3
add a,c
checkbit3:
sla c
rrc e
jr nc,checkbit4
add a,c
checkbit4:
sla c
rrc e
jr nc,checkbit5
add a,c
checkbit5:
sla c
rrc e
jr nc,checkbit6
add a,c
checkbit6:
sla c
rrc e
jr nc,checkbit7
add a,c
checkbit7:
sla c
rrc e
jr nc,all_done
add a,c
all_done:
ret
If you can see how that relates to the school book algorithm, then just know that the following does practically the same thing:;C is our "top" number.
;E is our "bottom" number.
;A will be our "accumulator"
xor a ;mad hax to set A to zero. Faster, smaller.
ld b,8
loop:
rrc e ;this rotates register 'e' right, putting the bottom bit as "carry" [out of the register].
jr nc,no_add ;nc == not carry. If "carry" out was zero, skip this step.
add a,c ;if carry out was 1, then add to our accumulator.
no_add:
sla c ;finally, shift our "top number" to the left in case we need to add this to the accumulator, too.
djnz loop ;aaand repeat, decrementing register B until zero (this is a specialized instruction on the Z80)
ret
I'm also guessing division would be the subtraction instead of addition, trunkating any remainder.Division is typically performed exactly like 'schoolbook' long division (until you get to higher precision, then you can use some state-of-the-art algorithms and math magic).
HL_div_C:
;Input:
; HL is the numerator
; C is the denominator. C<128
;Output:
; A is the remainder
; HL is the quotient.
xor a
ld b,16
loop:
add hl,hl ;this works like shifting HL left by 1. Overflow (thus, the top bit) is left in the carry flag
rla ;shift a left, rotating in the c flag as the low bit.
cp c ;compare a to c. Basically does A-C and returns the flags. If C>A, then there will be underflow setting the C flag.
jr c,skip ;skip the next two bytes if c flag is set (so A<C)
inc l ;we know the low bit of HL is 0, so incrementing HL will set that bit.
sub c
skip:
djnz loop
ret
ld b,8 - This must be telling the loop to repeat 8 times to check each bit, so, how does the loop relate to b? I'm thinking about how nested loops would work...
djnz loop - kindof like "goto" loop, with the automatic decrementing of register b?That is correct and that's why we initially do ld b,8. Keep in mind that djnz * and jr * are intended for small (ish) loops or redirecting to code relatively close by. It can jump backwards up to 126 bytes and forward up to 128 (back 1 byte is simply a slower way of performing rst 38h and I do not suggest it, back 2 bytes creates an infinite loop, back 0 bytes does nothing but waste 7 or 9 clock cycles). Most assemblers will warn you of out-of-bounds jumps.
rrc e - you say this rotates register e, is this the same as changing the register input from left to right?For example, if e=01111011, then rrc e would change it to e=10111101. The bottom bit gets returned in the c flag as well as being returned to the top bit of e. I used rrc * since rotating 8 times would leave it exactly how it was input. I could have used rr * or even sra * or srl *, but I prefer to avoid destroying registers if I can.
Division is typically performed exactly like 'schoolbook' long division (until you get to higher precision, then you can use some state-of-the-art algorithms and math magic).