
; Listing19t.s
; uaedbg 
; 
; (WinUAE 5.3.0 A1200 configuration with CPU 68030 !!!)
; Console-Debugger


uaedbg -  a complete and easy setup to understand the function

https://eab.abime.net/showthread.php?t=91321
https://eab.abime.net/showpost.php?p=1560529&postcount=141 ; my old question

I never understood this 'uaedbg' for a very long time. It was one of my alltime
big mysterious WinUAE things or one of my most unsolved question/problems on 
WinUAE. Finally paraj a EAB member could tell me the answer and the reason.

The reason is: To use 'uaedbg' you need to use an Amiga config with 32-bit
address space (i.e. 68030+ or 68020 non-EC) and set debug_mem=true in config
(in GUI that's Host->Miscellaneous->Debug memory space).

The general information: "won't work with 24-bit addressing" was for me to 
less. Normally I only use a A500 configuration. That was my computer in the
early 90's. Seldom I use a A1200 configuration. Maybe only for the AGA lesson
and I never change the CPU's. 

So I was happy that I finally got an uaedbg Debugger output.
Why is this not explained on the first line that I have to choose a CPU 68030
or higher? I had headaches if I read this word 'uaedbg'... 
Ok, now I can go forward. (I changend in my A1200 config the CPU to 68030)

These are the steps:
1. CPU
Take your existing A1200 configuration and replace the 68020 by a 68030 or
higher.

(Or you can leave the 68020 and add a Blizzard 1240)
You can get the roms from here:
https://ftp2.grandis.nu/turran/FTP/TheZone/files/_2015/expansion_boot_roms.zip

2. OS
uaedbg requires KS 2.0+ (mentioned in the first post in the EAB thread)

3. set debug_mem=true in config
WinUAE/GUI:  Host->Miscellaneous->Debug memory space

3b.
debugmem_start and debugmem_end? in config
I leave it as it is.

4. assembler for testprogram
The program should be compiled/assembled with compatible debug information
included (e.g. -g -gdb for bebbo's gcc port). With vasm symbols are 
automatically included unless you omit them explicitly.

5. easy test programm thats shows uaedbg function

Listing...
;------------------------------------------------------------------------------

start:
    ; Force screen to be shown
    move.l  $4.w,a6
    lea     dosname(pc),a1
    jsr     -408(a6)
    move.l  d0,a6
    lea     str(pc),a0
    move.l  a0,d1
    jsr     -948(a6)
.wait:
    bsr     test
    btst.b  #6,$bfe001
    bne.b   .wait
    rts
dosname:
	dc.b 'dos.library',0
str:
	dc.b 'test',10,0
    even
test:
    bsr     test2
.w:    
	move.l  $dff004,d0
    and.l   #$1ff00,d0
    bne     .w
    rts
val: 
   dc.l    0
test2:
    lea     val(pc),a0
    addq.l  #1,(a0)
    rts

;------------------------------------------------------------------------------		
vasm...
vasmm68k_mot -x -Fhunkexe -o hd\test Listing19t.s

6. How to start?
Then on the amiga side you start "uaedbg <youprrogram>" (uaedbg amiga side
program is included in the first post)

7. How to see the results?
After starting, it should automatically go to the debugger when the program
has loaded and show:

start:
70008008 [000000] 2c78 0004                movea.l $0004.w [0000212c],a6
Segment 1: 000003e9 70008000-7000805f
7000800c [000004] 43fa 0020                lea.l (pc,$0020) == $7000802e dosname,a1
Next PC: 70008010

You can see the symbols and you can debug them:
>m dosname
>d start

To debug the listings from lesson15 with uaedbg you have to create with vasm the
executable files.

The command line for vasm would be:

vasmm68k_mot -m68020 -Fhunkexe -nocase -quiet -o L15c Listing15c.s

and to clear up the following error message:
fatal error 13 in line 9 of "Listing15c.s": could not open <\Sources\startup2.s> for input
>       include "/Sources/startup2.s"   ; speichern copperlist etc.
aborting...

you have to change the path in the listings to:
include "..\Sources\Startup2.S" and incbin "..\Sources\xxxxx"



in Amiga Shell
>uaedbg test
																				; Debugger opens
;------------------------------------------------------------------------------
VPOS: 077 ($04d) HPOS: 226 ($0e2) COP: $000009b4
  D0 00000001   D1 0030CEBB   D2 00001000   D3 00C38DCC
  D4 00000005   D5 00000005   D6 0030E4BD   D7 00C33AEC
  A0 00C38DD1   A1 00C34BD8   A2 00C0F77C   A3 00C33AEC
  A4 00C35BD0   A5 00F96460   A6 00F96454   A7 700110F8
USP  700110F8 ISP  00C02598 SFC  00000000 DFC  00000000
CACR 00002111 VBR  00000000 CAAR 00000000 MSP  00000000
SR=0010 T=00 S=0 M=0 X=1 N=0 Z=0 V=0 C=0 IM=0 STP=0
Prefetch 7000800c 08390006 (1) 000e (ILLEGAL) 0839 (BTST) 0006 (OR) Chip latch 00003FAC
Segment 1: 000003e9 70008000-70008023
startup:
70008008 [000000] 6100 000e                bsr.w #$000e init == $70008018
Next PC: 7000800c
;------------------------------------------------------------------------------
>d pc
Segment 1: 000003e9 70008000-70008023
startup:
70008008 [000000] 6100 000e                bsr.w #$000e init == $70008018
7000800c [000004] 0839 0006 00bf e001      btst.b #$0006,$00bfe001
70008014 [00000C] 66f2                     bne.b #$f2 == $70008008 (T)
70008016 [00000E] 4e75                     rts  == $00c33e86
init:
70008018 [000010] 33f9 00df f006 00df f180 move.w $00dff006,$00dff180
70008022 [00001A] 4e75                     rts  == $00c33e86
70008024 9797                     sub.l d3,(a7) [00c33e86]
70008026 9797                     sub.l d3,(a7) [00c33e86]
70008028 9797                     sub.l d3,(a7) [00c33e86]
7000802a 9797                     sub.l d3,(a7) [00c33e86]
;------------------------------------------------------------------------------
>seg
Segment 1: 000003e9 70008000 - 70008023 (36)
Segment 2: 0000ffff 70010100 - 700110ff (4096) STACK
>
;------------------------------------------------------------------------------
>m init 1
70008018 33F9 00DF F006 00DF F180 4E75 9797 9797  3.........Nu....
>

....