Jump to content
IGNORED

Debugging an assembler program


twh/f2

Recommended Posts

In old days I had "Happy Freezer" hardware add-on in my Atari that made it possible to stop it and look at any memory location / register. Nowadays [F8] from Atari800Win works pretty good, too. In this monitor you can set breakpoints on memory locations and scanlines (!).

 

System.out.println(); approach may work, too - it worked for me anyway. Just

open 1,8,0,"H:OUT.TXT"

and

put 1

appropriate (ASCII) values. You will need only bin to ASCII hex conversion, but it is very simple. If you put CR LF along with the data, you can view the results directly in programmer's editor like UltraEdit. Do not forget to

close 1

 

For these macros you will need something like IOMAC.M65 or IOLIB.M65 with SYSEQ.M65

(for Mac65 and compatible crossassemblers). You even do not need DOS to be present in the memory.

 

If you are coding on real Atari and both approaches are not available, you can add one text line somewhere to your DL, write simple bin to hex screen codes routine and display hex values of chosen variables directly. Some kind of SLO-MO or just waiting for a keypress from time to time helps, too.

 

A last approach I used was to add few lines in DL that are displaying variable area, like

.byte $42

.word variables

.byte 2,2,...

 

On such a screen you can very quickly recognize many special values like 0 (empty space), 1 = "!", $FF, etc. It will not fix a bug, but may display an unexpected behaviour.

Edited by pirx
Link to comment
Share on other sites

On a real machine, use the built in debug in the Atari AsmEdit cartridge, DDT in MAC65, or an OS replacement with monitor like Omnimon.

 

On an emulator it's a bit easier as it has a built-in debugger (Atari800Win, that is). Plus if you want, it's easy to take snapshots of memory.

 

In any case, 6502 is a very simple language with only 3 main registers and limited number of addressing modes.

 

The simplest way I've found is to debug routines before incorporating them into your main program. Use test data, and keep the thing documented and it usually falls together nicely.

Link to comment
Share on other sites

System.out.println(); approach may work, too - it worked for me anyway. Just

  open 1,8,0,"H:OUT.TXT"

and

  put 1

appropriate (ASCII) values. You will need only bin to ASCII hex conversion, but it is very simple. If you put CR LF along with the data, you can view the results directly in programmer's editor like UltraEdit. Do not forget to

  close 1

 

For these macros you will need something like IOMAC.M65 or IOLIB.M65 with SYSEQ.M65

(for Mac65 and compatible crossassemblers). You even do not need DOS to be present in the memory.

 

This sounds in fact very interesting. Can you provide me an example? I am at a beginers level in writing 6502 code and not quite sure how to use the IOMAC stuff. But, this trick would -for sure- help me a lot! I could "tail" the debug log in a console!!! great!!

 

\twh

Link to comment
Share on other sites

What are you using to program a real machine or an EMU

 

If a real atari and a MAC65 cartridge you can use the built in debug mode and sigle step every line of code and at the sametime view all the registers and flags. I used to use this all the time when programming gives a very good view of what is happeneing and more important whats wrong with your code.

 

Andy

Link to comment
Share on other sites

Can you provide me an example? I am at a beginers level in writing 6502 code and not quite sure how to use the IOMAC stuff.

   *=$2000
   jmp start
   .include#IOMAC.TXT
;please note IOMAC must be included AFTER "*=$xxxx"
start
   open 1,8,0,"H:LOG.TXT"
;
;your code
;
   print 1,"variable "
   lda variable ;the variable you want to trace
   and #$F0
   lsr a
   lsr a
   lsr a
   lsr a 
   tax
   lda HexToASCII,x
   put 1;it was upper nibble
   lda variable
   and #$0F
   tax
   lda HexToASCII,x
   put 1;it was lower nibble
;
   lda #$0D;CR
   put 1
   lda #$0A;LF
   put 1
;
;
;
;
   close 1
   rts
HexToASCII
   .byte "0123456789ABCDEF"

 

The trick is the IOMAC.TXT I included here will not compile under any known to me crossassembler compatible with Mac65 - OMC65 will fail due to bug in the conditional macro compilation, nasm will compile bad code and ATASM does not accept macros and variables with dot ".".

I do suggest ATASM anyway because apart from this "." incompatibility it is the best MAC65 alike crossassembler available today (in my humble opinion), you will just need to replace "." with something else.

IOMAC.zip

Edited by pirx
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...