English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 30 December 2015, 17:37   #1
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Debugging messages in serial (small tutorial, mainly for cross-dev)

This is what I use when cross-developing. (linux host, fs-uae)
First you run this script on linux terminal:
Code:
#!/bin/sh
echo "1.Leave this running in the background,\n2.Run fs-uae with --serial-port=/tmp/vser at the end"
echo "3.On another terminal go type cat /tmp/hser"
echo "4.Use redirection from Amiga-side e.g. yourexe >ser: and all your stdout (printfs etc) will appear on linux"
OPTS=raw,echo=0,onlcr=0,echoctl=0,echoke=0,echoe=0,iexten=0
exec socat "$@" pty,$OPTS,link=/tmp/vser pty,$OPTS,link=/tmp/hser
Follow the instructions on terminal

Now, if you boot amiga in fs-uae, anything you send to serial is echoed in the linux terminal. Try in a CLI: date >ser:

Ok, this can be used for any program that can be run from CLI. Even if your program takes over screen, you just run it with >ser: and any printfs you put there for debugging will appear in linux terminal.

Now, the cooler thing, how about having this in asm

Code:
	move.l	#1234,d0
	move.l	d0,speed
	add	#100,d0
	DBUG "Alkis was here %ld %ld (stack: %lx)",speed,d0,sp
	jsr	halfd0
	DBUG "Alkis was here %ld %ld (stack: %lx)",speed,d0,sp
	rts

	section data
speed:	ds.l	1
and getting this in linux terminal?
Code:
Alkis was here 1234 1334 (stack: 7844CC4)
Alkis was here 1234 667 (stack: 7844CC4)
You'll need this macro
Code:
	XREF	_kprintf
_LVORawDoFmt    	EQU     -522	
_LVORawPutChar		EQU	-516	* Private function in Exec
_LVORawMayGetChar	EQU	-510
_AbsExecBase		EQU  	4
	XDEF _LVORawPutChar
	XDEF _LVORawDoFmt
	XDEF _LVORawMayGetChar
	XDEF _AbsExecBase
	
DEBUG	EQU	1
	
DBUG	macro
	ifd	DEBUG

	; save all regs
	movem.l	d0/d1/a0/a1,-(a7)
	IFGE	NARG-9
		move.l	\9,-(sp)		; stack arg8
	ENDC
	IFGE	NARG-8
		move.l	\8,-(sp)		; stack arg7
	ENDC
	IFGE	NARG-7
		move.l	\7,-(sp)		; stack arg6
	ENDC
	IFGE	NARG-6
		move.l	\6,-(sp)		; stack arg5
	ENDC
	IFGE	NARG-5
		move.l	\5,-(sp)		; stack arg4
	ENDC
	IFGE	NARG-4
		move.l	\4,-(sp)		; stack arg3
	ENDC
	IFGE	NARG-3
		move.l	\3,-(sp)		; stack arg2
	ENDC
	IFGE	NARG-2
		move.l	\2,-(sp)		; stack arg1
	ENDC

PULLSP	SET	(NARG)<<2		
	pea.l	n1\@
	jsr	_kprintf
	lea.l	PULLSP(sp),sp			
	movem.l	(a7)+,d0/d1/a0/a1
	bra.s	n2\@

n1\@	dc.b	\1,10,0
	cnop	0,2
n2\@
	endc
	endm
and then you do something like that (let's pretend the above code is in foo.asm)

Code:
vasmm68k_mot -Fhunk -o foo.o foo.asm
vlink -bamigahunk -o dbug foo.o /home/alex/Documents/FS-UAE/Hard\ Drives/AmigaHD/SC/lib/debug.lib
of course you have to change the path to the debug.lib

The DBUG macro must take a string argument, and then optional a variable number of arguments (0 and upto 8). Accepts the printf syntax, sort of.
Also, if you comment out the DEBUG equate then all DBUGs become nothing.

And that's it...
Hope someone finds it usefull.
alkis is offline  
Old 30 December 2015, 19:56   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
I do!!
jotd is online now  
Old 30 December 2015, 21:01   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
Possible WinUAE configs for similar serial logging:

Option 1: "-log -serlog" command line parameters can be used to see serial output in WinUAE's log window. (Even serial input work)

Option 2: config file win32.serial_port=tcp://localhost/<port> Use telnet client to connect. You can append /wait if you want emulation to wait until telnet client has connected.
Toni Wilen is online now  
Old 31 December 2015, 01:41   #4
bubbob42
Registered User
 
Join Date: Oct 2012
Location: Germany
Posts: 585
Thanks Toni - this is exactly what I need atm. Also a big thank you to alkis for starting this topic!
bubbob42 is offline  
Old 31 December 2015, 16:08   #5
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Any clues on how to integrate this in Blitz Basic? It could be quite helpful when debugging BLITZ mode programs.
idrougge is offline  
Old 31 December 2015, 17:15   #6
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Thanks a lot! I knew about debug.lib, but I had no idea you could tell the emulator to capture the serial output like this. Very useful script, it works fine on Mac OS X with no changes.

Quote:
Originally Posted by Toni Wilen View Post
Option 2: config file win32.serial_port=tcp://localhost/<port> Use telnet client to connect. You can append /wait if you want emulation to wait until telnet client has connected.
Is it the same as going to Host -> I/O Ports -> Serial Port, and selecting "tcp://0.0.0.0:1234/wait"?
Leffmann is offline  
Old 01 January 2016, 16:52   #7
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by idrougge View Post
Any clues on how to integrate this in Blitz Basic? It could be quite helpful when debugging BLITZ mode programs.
By putting debug.lib into a Blitz library, but there's probably something like this in dev/basic on Aminet already.
Leffmann is offline  
Old 22 February 2016, 14:16   #8
Geijer
Oldtimer
 
Geijer's Avatar
 
Join Date: Nov 2010
Location: VXO / Sweden
Posts: 153
Thumbs up

Quote:
Originally Posted by alkis View Post
This is what I use when cross-developing. (linux host, fs-uae)
...
Perfekt fit for my current requirements! Thank you very much!
Geijer is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial debugging while booting jman Coders. General 1 25 March 2012 03:02
Private Messages not possible andreas project.EAB 8 25 June 2002 23:46
Strange Messages Andrew support.Hardware 6 18 May 2002 19:29

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14912 seconds with 15 queries