English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 23 June 2022, 23:53   #1
hop
Registered User
 
Join Date: Apr 2019
Location: UK
Posts: 172
DisplayAlert asm not working on Kickstart 1.3

This simple DisplayAlert assembly language program does not display the alert on stock A500 KS1.3 in WinUAE. It works as expected on stock A1200 3.1.

Code:
	INCLUDE "intuition/intuition.i"	; RECOVERY_ALERT

	INCLUDE "lvo/exec_lib.i"
	INCLUDE "lvo/intuition_lib.i"	; _LVODisplayAlert

	SECTION code,code

	; Open intuition.library
	movea.l	4.w,a6			; ExecBase
	lea	intuitionName(pc),a1	
	moveq	#0,d0			; any version
	jsr	_LVOOpenLibrary(a6)
	tst.l	d0
	beq.b	.exit
	movea.l	d0,a6			; n.b. library's base address must be in A6 to call a system function

	move.l	#RECOVERY_ALERT,d0	; AlertNumber
	lea	string(pc),a0
	move.w	#28,d1			; Height
	jsr	_LVODisplayAlert(a6)

	; close intuition.library
	movea.l	a6,a1
	movea.l	4.w,a6
	jsr	_LVOCloseLibrary(a6)

.exit	rts

intuitionName	dc.b	"intuition.library",0
		EVEN
string		dc.w	16				; x pos in pixels (word)
		dc.b	16				; y pos in pixels (byte)
		dc.b	"Hello world!",0		; null-terminated string
		dc.b	0				; continuation byte = 0 means no more lines
Building with

Code:
vasmm68k_mot -Fhunk -kick1hunks -I%NDK%\Include_I -o displayalert.o -no-opt -wfail displayalert.s
vlink -bamigahunk -L%NDK%\lib -lamiga -o displayalert displayalert.o
I've tried debugging in WinUAE, and the DisplayAlert call just seems to return immediately. I tried stepping in but got hopelessly lost.

I wrote the equivalent code in C, built using vbcc (vc +kick13 -lauto) and it runs on A500 just fine.

Attached binary in case it is of use. Built using vasm 1.9a. vlink V0.17a. NDK 3.2 Release 4. Building on PC.

Thanks for any ideas - I can't figure this out.

EDIT: I have tried linking against the vbcc\targets\m68k-kick13\lib\amiga.lib instead of the NDK lib but that didn't help.
Attached Files
File Type: 7z DisplayAlert.7z (265 Bytes, 38 views)

Last edited by hop; 23 June 2022 at 23:55. Reason: More info
hop is offline  
Old 24 June 2022, 00:25   #2
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
I would change your height from move.w #28,d0 to moveq #28,d0, just incase there is something in the Highword in D1 before you use it.
Galahad/FLT is offline  
Old 24 June 2022, 00:35   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yup, that's why it doesn't work.
a/b is offline  
Old 24 June 2022, 08:20   #4
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,166
Good web-debugging Galahad!
jotd is offline  
Old 24 June 2022, 08:30   #5
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Also, you can ommit linking with amiga.lib since you don't use anything from the library.
alkis is offline  
Old 24 June 2022, 09:11   #6
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by jotd View Post
Good web-debugging Galahad!
I'm here all week \o/
Galahad/FLT is offline  
Old 24 June 2022, 11:24   #7
hop
Registered User
 
Join Date: Apr 2019
Location: UK
Posts: 172
Thanks but unfortunately setting height (D1) as a longword with moveq or move.l has not fixed it for me. It's documented as a word Param but I guess that could also be a mistake. The executable is being launched as the first thing in the startup-sequence.
hop is offline  
Old 24 June 2022, 12:32   #8
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
I assembled your code on my machine with an installed vbcc using the command line

vc -nostdlib alert.asm -o alert

and it worked at first try. Had to remove the INCLUDE directions and replace them by EQU because I don't have these include files, though.

Then I used D68k to disassemble both programs. Apparently in your load module the last dc.b 0 is cut off.

I'd suspect a bug in your version vasm.

yours:
Code:
D68k V2.0.8 MC68000-68060,MC68881/82,MC68851 Disassembler
Copyright 26.11.95 by Denis Ahrens

00000001 400ABBB4 00000040 00000054 401FE30C 00000001 00000001 00000000

					SECTION "",CODE       ;000 000084

000000	2C78 0004			MOVEA.L	$0004,A6
000004	43FA 002C			LEA	intuitionName(PC),A1
000008	7000				MOVEQ	#$00,D0
00000A	4EAE FDD8			JSR	-$0228(A6)
00000E	4A80				TST.L	D0
000010	671E				BEQ.B	L000001
000012	2C40				MOVEA.L	D0,A6
000014	203C 0000 0000			MOVE.L	#$00000000,D0
00001A	41FA 0028			LEA	string(PC),A0
00001E	323C 001C			MOVE.W	#$001C,D1
000022	4EAE FFA6			JSR	-$005A(A6)
000026	224E				MOVEA.L	A6,A1
000028	2C78 0004			MOVEA.L	$0004,A6
00002C	4EAE FE62			JSR	-$019E(A6)
				L000001:
000030	4E75				RTS

				intuitionName:
000032	696E 7475			dc.l	"intu"
000036	6974 696F			dc.l	"itio"
00003A	6E2E 6C69			dc.l	"n.li"
00003E	6272 6172			dc.l	"brar"
000042	7900				dc.w	$7900		;"y "
				string:
000044	0010 1048			dc.l	$00101048	;"   H"
000048	656C 6C6F			dc.l	"ello"
00004C	2077 6F72			dc.l	" wor"
000050	6C64 2100			dc.l	$6C642100	;"ld! "
mine:
Code:
D68k V2.0.8 MC68000-68060,MC68881/82,MC68851 Disassembler
Copyright 26.11.95 by Denis Ahrens

00000001 400A9BBC 00000040 00000050 401FE30C 00000003 00000003 00000000

					SECTION "",CODE       ;000 000080

000000	2C78 0004			MOVEA.L	$0004,A6
000004	43FA 0026			LEA	L000002(PC),A1
000008	7000				MOVEQ	#$00,D0
00000A	4EAE FDD8			JSR	-$0228(A6)
00000E	4A80				TST.L	D0
000010	6718				BEQ.B	L000001
000012	2C40				MOVEA.L	D0,A6
000014	7000				MOVEQ	#$00,D0
000016	41FA 0026			LEA	L000003(PC),A0
00001A	721C				MOVEQ	#$1C,D1
00001C	4EAE FFA6			JSR	-$005A(A6)
000020	224E				MOVEA.L	A6,A1
000022	2C78 0004			MOVEA.L	$0004,A6
000026	4EAE FE62			JSR	-$019E(A6)
				L000001:
00002A	4E75				RTS

				L000002:
00002C	696E 7475			dc.l	"intu"
000030	6974 696F			dc.l	"itio"
000034	6E2E 6C69			dc.l	"n.li"
000038	6272 6172			dc.l	"brar"
00003C	7900				dc.w	$7900		;"y "
				L000003:
00003E	0010 1048			dc.l	$00101048	;"   H"
000042	656C 6C6F			dc.l	"ello"
000046	2077 6F72			dc.l	" wor"
00004A	6C64 2100			dc.l	$6C642100	;"ld! "
00004E	0000				dc.w	$0000
thomas is offline  
Old 24 June 2022, 13:40   #9
hop
Registered User
 
Join Date: Apr 2019
Location: UK
Posts: 172
Quote:
Originally Posted by thomas View Post
Apparently in your load module the last dc.b 0 is cut off. I'd suspect a bug in your version vasm.
Thanks very much. This has caught me out before. To use the KS1.3 loader vlink requires the -Z option to prevent it from stripping trailling zero bytes.

Unfortunately this doesn't seem to fix the issue in this case. I've tried adding a dummy non-zero byte at the end and that hasn't worked either. Will investigate.
hop is offline  
Old 24 June 2022, 14:18   #10
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Last zero is not "missing", it's in the combined code+bss hunk (22 longwords total, 21 actual, 1 bss) that KS1.3 doesn't clear.
When I loaded your exe into memory and changed the problematic move.w to moveq/nop it worked fine (because I was lucky with memory being empty), but I didn't check the hunk structure. The problem is that the final byte, explicitely set to zero, is put together with extra 3 byte padding (hunk size is in longowords) into BSS. KS1.3 doesn't clear that, KS2.0+ does.
I'm using asm-one/pro and the code is generated properly, only required fix is setting d1 as longword. Try adding 3 zeroes (to round up your hunk size manually), or better yet a non-zero byte after the last zero (cont. byte).

edit: Just remembered that phx said vasm default mode is KS2.0 and any trailing zeroes are converted to BSS. Adding extras zeroes won't help, add a non-zero at the end and it should work.
Not sure why -Z doesn't work. Examine the hunk structure (load exe as raw binary), there should be no combined CODE+BSS if linked for KS1.3 (hunk size should be $16=22 longwords in both cases).

Last edited by a/b; 24 June 2022 at 14:42.
a/b is offline  
Old 24 June 2022, 17:17   #11
hop
Registered User
 
Join Date: Apr 2019
Location: UK
Posts: 172
Ah. It is working sorry. I was launching the wrong exe after the -Z / non-zero-end-byte change (repro case vs real code). Thanks for the support.

I must try to remember this V34 LoadSeg + default vlink stripping combo gotcha!

Quote:
Originally Posted by Galahad/FLT View Post
I would change your height from move.w #28,d0 to moveq #28,d0, just incase there is something in the Highword in D1 before you use it.
It does actually look like DisplayAlert requires the full longword to be written though. Maintaining the hunk structure by using move.w vs moveq + nop proves this. It looks like the signature changed the type of height from word to ULONG at some point

Code:
BOOL DisplayAlert( ULONG alertNumber, CONST_STRPTR string, ULONG height );
So there were two issues here. Thanks

Last edited by hop; 24 June 2022 at 17:31.
hop is offline  
Old 24 June 2022, 17:46   #12
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Hurrah, we got there
Galahad/FLT is offline  
Old 26 June 2022, 20:51   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by a/b View Post
Just remembered that phx said vasm default mode is KS2.0 and any trailing zeroes are converted to BSS.
Yes and no. vasm prefers 2.0 hunks and needs
-kick1hunks
to be really compatible to Kickstart 1.x. But, unlike vlink, vasm does not remove trailing zeroes unless requested by
-databss
, when writing an executable instead of an object (
-Fhunkexe
).

Work on vasm started 20 years ago and vlink is even 25 years old. At that time I couldn't imagine anybody would write new programs for Kickstart 1.x again. This might explain the presets. Although I admit that it is better design to enable additional features with options, instead of having to disable them.

Quote:
Not sure why -Z doesn't work.
This is the vlink option to not remove trailing zeroes.
phx 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
Blizkick EXTRESBUF working only from internal kickstart Lisko support.Apps 4 17 April 2021 09:10
Looking for Asm software and iff converter installable on HD (kickstart >= 2.04) fstarred support.Apps 5 12 April 2018 23:59
How is Workbench 3.1 working on Kickstart 2.04? Sim085 support.Other 6 06 August 2013 21:40
dos/exec/intuition asm tutorials for Kickstart 1.3 Photon Coders. General 19 05 January 2007 19:54

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 21:33.

Top

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