Page 2 of 6

Re: Howto try small machine code programs in BASIC ?

Posted: Tue Oct 01, 2013 11:02 pm
by Sarah
jedie wrote:But can i print the value (in this case $58 == 88) of accumulator A to screen?
Here are some options:
  • Use a debugger
  • Make a simple routine that outputs the hex value using two ascii characters
  • JSR 38266 outputs the decimal value of D register

Re: Howto try small machine code programs in BASIC ?

Posted: Tue Oct 01, 2013 11:38 pm
by Alastair
The text screen starts at address $400 and ends at address $5FF, so any STA instruction to any address within that range (inclusive) will print the contents A to the screen. Try the following which should output all 256 text mode characters near the middle of the screen, you may omit the delay loop if desired:

Code: Select all

        CLRA
LOOP    STA $4EF        ; Store A at address $4EF
        LDY #$800       ; Delay value, the larger the value the greater the delay
DELAY   LEAY -1,Y       ; Part of the delay loop
        BNE DELAY       ; End of the delay loop
        INCA
        BNE LOOP
Note that the STA ,X+ instruction in the example you gave earlier stores the contents of A to the address value contained in X then increments X. This is used to fill the whole text screen with the contents of A.

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 8:41 am
by jedie
Sarah wrote:Use a debugger
Which one?

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 9:36 am
by jedie
tormod wrote:Yes, there is a routine to print the value of D.
Sarah wrote:JSR 38266 outputs the decimal value of D register
I get it:

Code: Select all

10 ' MACHINE CODE LOADER
20 READ LA  ' LA = LOAD ADDRESS (START OF PROGRAM)
30 READ EA  ' EA = ADDRESS OF FIRST INSTRUCTION
40 PA = EA  'TO BE EXECUTED
50 READ HB$ ' HEX CONSTANTS
60 IF HB$="END" THEN 100
70 POKE PA,VAL("&H"+HB$) ' POKE VALUE INTO MEMORY
80 PA = PA + 1  ' INCREMENT ADDRESS
90 GOTO 50
100 PRINT "AUTORUN WITH EXEC";EA;":"
105 PRINT "-------------------------------"
110 EXEC EA ' AUTORUN
114 PRINT
115 PRINT "-------------------------------"
120 PRINT "END ADDRESS:"; PA-1
130 PRINT "RUN AGAIN WITH EXEC";EA
149 ' LOAD ADDRESS:
150 DATA 20001
159 ' EXECUTE ADDRESS:
160 DATA 20001
165 ' MACHINE CODE IN HEX
170 DATA 34,12      ' PSHS A,X       ; Save registers A, X
180 DATA CC,58,58   ' LDD $5858      ; $5858 == 22616
190 DATA BD,95,7A   ' JSR 38266      ; outputs the decimal value of D register
260 DATA 35,92      ' PULS A,X,PC    ; Restore and return
270 DATA END
It display 22616 on screen ;)

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 11:47 am
by Sarah
Are you doing all your assembly by hand?

You'd surely find it easier to use an assembler like DREAM. It's straightforward to launch (execute) the assembled program within DREAM too. If you have ALLDREAM then it comes with the DREAMBUG debugger built-in, which isn't especially easy to use but can be handy at times.

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 1:56 pm
by jedie
I have tried ALLDREAM and ", without success. I get always "FULL"

I looked into Dragondata_alldream_manual.pdf and it seems that's very complicated to use, isn't it?

I also tried DskDream for Dragon DOS, but can't LOAD or RUN in XRoar. The emulator hangs.

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 6:36 pm
by sixxie
Coding on the machine, my preferred variant was DOS-Dream (you get DOS, you get an assembler, you don't have to lose any RAM to the assembler, bar your own program text).

Not too complicated, just a little terse as anything that has to fit in such a small space is bound to be.

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 6:48 pm
by Sarah
If you're getting FULL when trying to start DREAM then you haven't allocated any/enough memory with CLEAR.

The built-in editor is pretty easy to use IMO; certainly much easier than BASIC. There's not much more you need to know to get started and most of it is on page 27 of the manual. BREAK then A to assemble. BREAK then X to execute or BREAK Q to go back to editing.

If you're assembling by hand you'll surely find the complexity too much trouble before long! ;)

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 6:48 pm
by jedie
sixxie wrote:Not too complicated, just a little terse as anything that has to fit in such a small space is bound to be.
Good idea!

Re: Howto try small machine code programs in BASIC ?

Posted: Wed Oct 02, 2013 10:34 pm
by zephyr
jedie wrote:I have tried ALLDREAM and ", without success. I get always "FULL"

I looked into Dragondata_alldream_manual.pdf and it seems that's very complicated to use, isn't it?
There are other assemblers available for the Dragon.

Encoder 09
viewtopic.php?f=7&t=286

Dasm
viewtopic.php?f=7&t=287

viewtopic.php?f=4&t=285&hilit=dasm&start=10#p1799