Right, i've got my program working and it does what its supposed to do. You will see in the code that i have several Macros and i think there is something wrong in the 'UpToLow' Macro, so just look for that label. I cant figure it out... basically what the program should do is read in a string such as a name and it must be in mixed case, so for example JoHn. The program will convert this string and display it as JOHN and john. But at the end of the lower case one it shows a minus sign which is weird. My suspicion is that the program is also converting the carriage return <cr> at the end. Any help that you can offer will be very much appreciated people ;)

* Full Name: Osman Malik
* Course: BSc Computer Science
* Group: A1
* Tutor: Terry Carrol
* ID Number: W11246196
* Filename: LPG401LAB3ex1oms.a
* Date Written: 28/02/2009
* Last Updated: 09/03/2009
*Structure and use of Macros
*Key Words MACRO, ENDM, Parameter, label/@

	nam	Macros 
	ttl	Program to demo use of simple IO Macros and Subroutines
	use	<oskdefs.d>			1. Include symbol definition file
Edition		equ	1			2. Identify the version
Typ_Lang		equ	(prgrm<<8) +Objct		3. The final code will be the object code
Attr_rev		equ	(ReEnt<<8) +0		4. And re-entrant with no revisions
Stacksize		equ	256			5. Initial user stack size
	psect	LPG401LAB3ex1oms, Typ_Lang, Attr_Rev, Edition, Stacksize, Start

*Input requests here
Msg:	dc.b	"Please type in your name here using mixed case:",C$CR,C$LF
Len_Msg:	equ	*-Msg

*String lengths here
String_In:		ds.b	100
Len_String_In:	dc.l	0

*Cursor control values here
NewLine:		dc.b	C$CR,C$LF
Len_NewLine:	equ	*-NewLine

InOut:	MACRO		Declaration of input/output Macro
	move.l	#1,d0
	move.l	\1,d1
	lea	\2(a6),a0
	os9	I$\3

		move.l	d5, \1		input string address in a5, count in d5 result		*					into string address
		lea	\2(a6),a5		lea to move addresses

LTUO\@:		move.b	(a5),d4		
		cmp	#$60,d4		Character in d4
		bmi.s	LTU1\@		Test if it is uppercase
		sub.b	#$20,d4		if uppercase then subtract

LTU1\@:		move.b	d4, (a5)+		
		dbra	\1,LTUO\@

		move.l	d5,\1		input string address in a5, count in d5 result
*					into string address
		lea	\2(a6),a5		lea to move addresses		
		adda	\3#1,a5
UTLO\@:		move.b	\4(a5),d4	
		cmp	#$60,d4		Character in d4
		bgt.s	UTL1\@		Test if it is lowercase
		add.b	#$20		if lower case then add

UTL1\@:		move.b	d4, (a5)\5
		dbra	\1,UTLO\@

*Ask for and read in random string
Start:	InOut	#Len_Msg,Msg,Write
	InOut	#2,NewLine,Write
	InOut	#Len_String_In,String_In,ReadLn
*Save total string length
	move.l	d1,Len_String_In(a6)
*Start the conversions
	move.l	Len_String_In(a6),d7	Get string length
*Adjust to the correct loop size
	move.l	d7,d6
	InOut	#2,newline,Write
	LowToUp	d6,String_In

test1:	InOut	d7,String_In,Write	
	InOut	#2,NewLine,Write

test2:	move.l	d7,d6
	UpToLow	d6,String_In,*,,+
	InOut	d7,String_In,Write

*Exit system
	clr.l	d1
	os9	F$Exit

ok it's been a while since I have done this but just from a brief view of your code I think you are right. Unless I am mistaken I believe you have to strip the carriage return and append a null termination character at the end of your string when you read it in. I could be wrong but it dosen't look like your doing that. I will have to study the code a little more.

Hi jt_murphree! Thank you for your reply, i really appreciate it. Its surprising how someone else's point of view can benefit. I hadn't thought of returning a null value to the operating system after i've read the value stored in the string. From the program you can see the i've named my 3rd Macro UpToLow, after the test2 label the last line of code before F$Exit (InOut d7,String_In Write) i can try and use a null operation which il have to look up. I'll try that and if it doesn't work i need to go back and check my ascii values and ensure i've set the code up correctly. Maybe i need to use -(an) and (an)+ ?

This article has been dead for over six months. Start a new discussion instead.