English Amiga Board


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

 
 
Thread Tools
Old 22 March 2013, 23:34   #1
demolition
Unregistered User
 
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 44
Posts: 4,190
Direct serial port read/write

I wanted to try to control the Amiga from the PC (to transfer small programs and run them etc.) so I thought it could be fun and relatively simple to do this through the serial port.

I found an example here but I have a few questions about the code, although it is very simple, but I'm sure the knowledgable people here can get me started with it. The author didn't bother to put any comments in it.

Here it is, with my comments added:
Code:
;routine for writing a single byte to the serial port without system calls.
  s: 	moveq		#0,d0                   ;
 	lea		data,a0                 ; a0 is now pointer to data
 	moveq		#6,d2                   ; number of bytes to send
 	move.w		#%0000001000000000,d3   ; Set stopbit
  writeit:
 	clr.b		d0		        ;
 	move.w		d3,d0                   ; Prepare d0 by setting stopbit
 	move.b		(a0)+,d0                ; Copy byte from data block and update pointer to next byte
 	move.b		d0,$dff030	        ; Put data in serial output buffer
 	clr.b		d1		       ; Why clear this?
 	move.b		$dff018,d1              ; Get data from serial input buffer
 	rol		#3,d1                  ;
 	btst		#1,d1                  ; Couldn't these two lines be replaced with 'btst #14,d1'?
 	bne		wait
  	cmp		#0,d2                   ; Are we done with all the data?
 	dbne		d2,writeit              ; Nah, go jump
 	rts                                     ; Ok, we are done
  	 
wait: 	btst	#1,d1                           ; Will this value ever change in the loop?
 	bne	wait                            ; Potentially wait forever?
 	beq	writeit
  
data: 	dc.b	'henrik'
Seems straightforward, but I have a few questions that I put in the comments. Any thoughts on this? I don't want to copy code, just understand it so I can make my own.

Edit: Looking at it again, I can see I first missed that he's only reading a byte from $dff018 and that bits 8+ in d1 is only written to with the rol instruction, although I'm not sure why he does this.

Last edited by demolition; 22 March 2013 at 23:42.
demolition is offline  
Old 23 March 2013, 01:01   #2
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
I like the data in the source there!
Photon is offline  
Old 23 March 2013, 01:05   #3
prowler
Global Moderator
 
prowler's Avatar
 
Join Date: Aug 2008
Location: Sidcup, England
Posts: 10,300
Yes, I imagine you would.
prowler is offline  
Old 23 March 2013, 01:29   #4
demolition
Unregistered User
 
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 44
Posts: 4,190
It's not your source by any chance (seeing as it's also from a swedish site)?
demolition is offline  
Old 23 March 2013, 01:49   #5
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
Hehe, no. I made a pretty fast parallel transfer routine from Amiga to C64 at one point.

BTW, this is just one end. Why not write how you set up the other end as well?

Actually, you're doing it the wrong way round! The Amiga should of course control the PC!

Not as silly as it sounds, I've often thought about writing a small program with a simple set of commands to give the Amiga the ability to make HTTP-requests and get data back, so that it would be able to access capable online resources and databases.

But it seems so much better to not need the PC. Still expecting ethernet stack+http that works on all Amigas I guess. Anyway, just dreamin'. All Amigas still couldn't handle surfing or streaming, but a command like 'Wikisearch <keyword>' or 'highscore.com/update.php?game=PunisherPenguin&handle=Photon&score=1gajillion' would be very low in requirements and data transferred, but still empower Amigas in a big way.
Photon is offline  
Old 23 March 2013, 02:05   #6
demolition
Unregistered User
 
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 44
Posts: 4,190
Well, the other end will be a PC running W7 with a USB-RS232 interface, so no asm there..

My idea was to put a program into the bootblock of a floppy which made it possible for me to transfer data from the PC to any address in the Amiga, read out data, running software (by making a JSR to a given address) etc. If the program you tested would crash, you just reset the Amiga and it would be ready to take orders again after a few seconds.
Combined with an automated upload from the PC, this would make it easy for me to quickly test small pieces of code on a real Amiga instead of in WinUAE which is not always accurate.
Actually, when I first tried how to use the copper on the Amiga, I could see the color changes in WinUAE but on the real Amiga the screen remained black. With an automated transfer setup, this would be much easier to get right.
demolition is offline  
Old 23 March 2013, 03:59   #7
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,839
This code seems like utter nonsense to me. Do yourself a favor, and find some good code.
Thorham 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
read/write Cd error help amigang support.WinUAE 1 30 July 2010 22:57
read but wont write Dave_wb support.Hardware 0 09 December 2006 14:04
Read\Write Errors..... THX1138 support.Apps 10 13 October 2004 15:24
Read/Write error? one1 support.Games 8 04 June 2003 23:23
CD Read Write Errors Stom support.WinUAE 2 07 June 2002 18:46

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 15:46.

Top

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