Dr Do Posted April 2, 2021 Share Posted April 2, 2021 (edited) ** EDIT: Problem described below now solved ** Sorry if this is the wrong place to post newbie questions like the one that follows. I've been trying to learn 6502 assembly, but it hasn't taken me long to get stuck. I was trying one of the examples from "Machine Language for Beginners", which was supposed to put ten "A"s on the screen. I soon realised that the code in the book needed tweaking to work, and so after a bit of trial and error came up with this... *=20000 ldy #10 loop lda #33 sta (88),Y dey cpy #0 bne loop brk (Excuse the tab spacing, it was lined up properly in the code edit window!) If I compile this in ATasm and then attempt to run the object code in the Atari800Win emulator using DOS Option L, it will display 10 "A"s as intended but then crash straight away. Changing the compile address from $4E20 (for example to $0600) or changing the last instruction to "brk" (or removing it completely) leads to the emulated machine crashing as soon as the object code is started. But switching to WUDSN (with the opening statement changed to "org" for the MADS compiler) makes the code behave differently; there, it causes nothing to happen except the debugger opening with a message about an "illegal operation". Sometimes, if I run it and then start Altirra separately then it will behave the same way as Atari800Win did. Changing "brk" to "rts" though will cause WUDSN to open up Altirra automatically, which will then display the As but immediately reboot into BASIC - which makes sense...I think? All this is leaving me scratching my head, but I'm guessing there's a simple solution. Any suggestions please? Edited April 3, 2021 by Dr Do Quote Link to comment Share on other sites More sharing options...
vitoco Posted April 2, 2021 Share Posted April 2, 2021 (edited) You need to change the BRK instruction to something else, such as an endless loop ("completed jmp completed") or a jump to another location to give the control back to, for instance DOS. I think that using RTS with a *=$2E2 .word 20000 might return control to DOS, but it will depend on the DOS or the loader you use. If you are just creating an XEX and run it from the PC with a double click or from your developing framework, probably the best option is the endless loop for tests. Edited April 2, 2021 by vitoco typo 1 Quote Link to comment Share on other sites More sharing options...
Dr Do Posted April 3, 2021 Author Share Posted April 3, 2021 12 hours ago, vitoco said: You need to change the BRK instruction to something else, such as an endless loop ("completed jmp completed") or a jump to another location to give the control back to, for instance DOS. I think that using RTS with a *=$2E2 .word 20000 might return control to DOS, but it will depend on the DOS or the loader you use. If you are just creating an XEX and run it from the PC with a double click or from your developing framework, probably the best option is the endless loop for tests. Now why didn't I think of that? Thanks vitoco, problem solved. Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 3, 2021 Share Posted April 3, 2021 (edited) For what it's worth - the lda #33 could stay outside the loop start to save cycles. The cpy #0 isn't needed. Practically any instruction that modifies a register or memory location (RTI being one exception) will modify some of the P flags to reflect what's happened. So for a DEY, the Z and N flags will reflect zero or negative state. Edited April 3, 2021 by Rybags 1 1 Quote Link to comment Share on other sites More sharing options...
+skr Posted April 20, 2021 Share Posted April 20, 2021 Make sure to checkout the tutorials JAC! made: http://www.wudsn.com/index.php/productions-atari800/tutorials They are a big help in getting started with assembly. 2 1 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.