jp48 Posted March 1, 2016 Share Posted March 1, 2016 Hi, I would like to write BatariBasic software, where TIA and sound registers would be used as numerical addresses instead of names. Mostly POKE-type of addressing, where loop index(es) are used as direct address(es) and values send to them. Perhaps using asm with LDA/STA sequence ? Any tips ? Thanks ! Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 2, 2016 Share Posted March 2, 2016 Just reference the proper register name as a variable. E.g AUDC0=0 If you really wish to use locations, then dim your own variables. dim goober=$20 And the assign or test using the name you dimmed. Quote Link to comment Share on other sites More sharing options...
jp48 Posted March 2, 2016 Author Share Posted March 2, 2016 Does this work: dim ADDR=a:dim VAL=b ADDR=$15:VAL=12 asm LDA VAL STA ADDR end Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 2, 2016 Share Posted March 2, 2016 Not quite. That takes the 12 stored in the RAM at "b" and stores it in "a". This is what you want... dim ADDR=$15 dim VAL=b VAL=12 ADDR=VAL Or without the intermediate variable... dim ADDR=$15 ADDR=12 Or using the official register name... dim VAL=b VAL=12 AUDC0=VAL The assembly isn't required, but here's a version with it... dim VAL=b VAL=12 asm lda VAL sta AUDC0 ; or sta $15 end all of those examples store 12 in the AUDC0 register at $15. Pick the one that suits you. 1 Quote Link to comment Share on other sites More sharing options...
jp48 Posted March 2, 2016 Author Share Posted March 2, 2016 Thanks of these ! What I am trying to do is avoid using constants in TIA registers, I picked last of your examples, how about this: dim VAL=b VAL=12 for i=$15 to $21 asm lda VAL sta i end next ie. using assembly (or any other means) to store value directly to (TIA) register value. Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 2, 2016 Share Posted March 2, 2016 The contents of "i" vary with your code, not the location. Try this... dim ADDR=$0 dim VAL=b for i=$15 to $21 ADDR[i]=VAL next Quote Link to comment Share on other sites More sharing options...
jp48 Posted March 2, 2016 Author Share Posted March 2, 2016 Yes, thanks, that do the job !! Quote Link to comment Share on other sites More sharing options...
bogax Posted March 6, 2016 Share Posted March 6, 2016 (edited) The contents of "i" vary with your code, not the location. Try this... dim ADDR=$0 dim VAL=b for i=$15 to $21 ADDR[i]=VAL next one of the things I really like about Bb is the way it does this and getting rid of that clumsy peek-poke stuff I just wish we had register variables you don't need a name all of these produce correct code (but of course writing to ROM is not very useful) rem if you want to store to a numeric location use indexing with an index of 0 a = 255 $d6[0] = 255 a[0] = 255 214[0] = 255 rem a[$07] is h h = a[$07] 0[221] = 255 $ABCD[a] = h $ABCD[a] = 16383[h] testd[$FF] = testd[1] data testd 00, 00, 00, 00 end 1631 f45d .L00 ; rem if you want to store to a numeric location use indexing with an index of 0 1632 f45d 1633 f45d . 1634 f45d ; 1635 f45d 1636 f45d .L01 ; a = 255 1637 f45d 1638 f45d a9 ff LDA #255 1639 f45f 85 d6 STA a 1640 f461 . 1641 f461 ; 1642 f461 1643 f461 .L02 ; $d6[0] = 255 1644 f461 1645 f461 a9 ff LDA #255 1646 f463 a2 00 LDX #0 1647 f465 95 d6 STA $d6,x 1648 f467 . 1649 f467 ; 1650 f467 1651 f467 .L03 ; a[0] = 255 1652 f467 1653 f467 a9 ff LDA #255 1654 f469 a2 00 LDX #0 1655 f46b 95 d6 STA a,x 1656 f46d . 1657 f46d ; 1658 f46d 1659 f46d .L04 ; 214[0] = 255 1660 f46d 1661 f46d a9 ff LDA #255 1662 f46f a2 00 LDX #0 1663 f471 95 d6 STA 214,x 1664 f473 . 1665 f473 ; 1666 f473 1667 f473 . 1668 f473 ; 1669 f473 1670 f473 .L05 ; rem a[$07] is h 1671 f473 1672 f473 . 1673 f473 ; 1674 f473 1675 f473 .L06 ; h = a[$07] 1676 f473 1677 f473 a2 07 LDX #$07 1678 f475 b5 d6 LDA a,x 1679 f477 85 dd STA h 1680 f479 . 1681 f479 ; 1682 f479 1683 f479 .L07 ; 0[221] = 255 1684 f479 1685 f479 a9 ff LDA #255 1686 f47b a2 dd LDX #221 1687 f47d 95 00 STA 0,x 1688 f47f . 1689 f47f ; 1690 f47f 1691 f47f . 1692 f47f ; 1693 f47f 1694 f47f . 1695 f47f ; 1696 f47f 1697 f47f .L08 ; $ABCD[a] = h 1698 f47f 1699 f47f a5 dd LDA h 1700 f481 a6 d6 LDX a 1701 f483 9d cd ab STA $ABCD,x 1702 f486 . 1703 f486 ; 1704 f486 1705 f486 .L09 ; $ABCD[a] = 16383[h] 1706 f486 1707 f486 a6 dd LDX h 1708 f488 bd ff 3f LDA 16383,x 1709 f48b a6 d6 LDX a 1710 f48d 9d cd ab STA $ABCD,x 1711 f490 . 1712 f490 ; 1713 f490 1714 f490 .L010 ; testd[$FF] = testd[1] 1715 f490 1716 f490 a2 01 LDX #1 1717 f492 bd 9d f4 LDA testd,x 1718 f495 a2 ff LDX #$FF 1719 f497 9d 9d f4 STA testd,x 1720 f49a . 1721 f49a ; 1722 f49a 1723 f49a . 1724 f49a ; 1725 f49a 1726 f49a . 1727 f49a ; 1728 f49a 1729 f49a . 1730 f49a ; 1731 f49a 1732 f49a .L011 ; data testd 1733 f49a 1734 f49a 4c a1 f4 JMP .skipL011 1735 f49d testd 1736 f49d 00 00 00 00 .byte.b 00, 00, 00, 00 1737 f4a1 1738 f4a1 .skipL011 1739 f4a1 . Edited March 7, 2016 by bogax Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 7, 2016 Share Posted March 7, 2016 Hah, didn't think about using a straight number with array notation, but I can see how valid assembly would be generated. Very cool. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.