12 August 2016, 01:29 | #1 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 399
|
Help with VPrintf
Hi I'm trying to work out how to use VPrintf.
Here's my program and I want it to output 45 but instead it is outputting 133659 **** Include exec/types.i include exec/libraries.i Include exec/exec_lib.i include dos/dos_lib.i Include macros.i start: lea dos_name(pc),a1 CALLEXEC OpenLibrary move.l d0,dosbase beq.s exit print_text: move.l #format_text,d1 move.l #text,d2 CALLSYS VPrintf,dosbase exit: move.l dosbase,a1 CALLEXEC CloseLibrary rts dos_name: dc.b 'dos.library',0 dosbase: ds.l format_text: dc.b '%1d',0 text: dc.b '45',0 |
12 August 2016, 01:31 | #2 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 399
|
Ugh my code In the post lost its formatting.
|
12 August 2016, 01:50 | #3 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Code:
text: dc.b '45',0 Code:
text: dc.l 45 |
|
12 August 2016, 02:51 | #4 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 399
|
Thank you yes there was a typo in what it output. I understand now that it is actually outputting the decimal values of the ascii for each character in the string. Your hint outputs a 0. I'm still confused as to how I can fix this... and I recently graduated with a degree in computer science haha. This is my first time with assembly.
|
12 August 2016, 03:10 | #5 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Code:
text: dc.w 45,0 |
|
12 August 2016, 03:51 | #6 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,844
|
|
12 August 2016, 03:55 | #7 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 399
|
I tried that and it wouldn't work and I was pulling my hair out and then I thought maybe the text needs aligning... so I wrote even above the text label and voila it works! Thanks for your help
|
12 August 2016, 16:41 | #8 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 722
|
Also it won't work at all if you pass a really long parameter on cli (~50 chars)
and it will probably crash cause exit shouldn't close the library (cause the first reason it's at exit was that it couldn't open the library). PS: The reason that it won't work is you forgot to specify contents of d0 and upon entry a0 points to the cli parameter string and d0 holds the length of that. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|