English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language

 
 
Thread Tools
Old 01 May 2021, 16:29   #1
Apollo
Registered User

Apollo's Avatar
 
Join Date: Sep 2008
Location: Germany
Age: 47
Posts: 131
vbcc - asm/c mix - variables in bss get extended to long

hello,
currently I play around with some code in C and Asm using the vbcc/vlink/vasm family. To make it more interesting I am using the small code and small data model. Using the docs and some disassembling with IRA I came along quite quickly.

Originally I defined local variables in Assembler and C parts. Then I came aware that the startup code is only clearing the BSS content of vars from the C part so I 'moved' over all variables from the Assembler part to (global) C and XREF'ing them, no problem.

Now I see that all variables get 'extended' to DS.L regardless of their original size. Of course this doesn't make a difference for the size of the executable but still I wonder did I make something wrong here?

Code:
#include "amigasupp_c.h"

struct DosLibrary *DOSBase;
struct GfxBase *GfxBase;
struct IntuitionBase *IntBase;
struct Task *ThisTask;
struct CopList *OldCopList;
struct View *OldView;
APTR WBScreen;
ULONG OldRes;
UWORD OldIntenar;
UWORD OldIntreqr;
UWORD OldDmaconr;
UWORD HasVBR;
UWORD KickVersion;
[...]
the Makefile

Code:
NAME = hwtest
VBCC = /opt/vbcc
TARGET = kick13m
CC = $(VBCC)/bin/vc
LD = $(VBCC)/bin/vc
AS = $(VBCC)/bin/vasmm68k_mot
INCDIR = /opt/NDK_3.9/Include/include_h
CFLAGS = +$(TARGET) -g -sc -sd -c99 -I$(INCDIR)
LDFLAGS = +$(TARGET) -g -sc -sd -lamiga
ASFLAGS =-I/opt/NDK_3.9/Include/include_i -quiet -m68000 -Fhunk -linedebug
OBJDIR = build/
EXE = $(NAME).exe
C_SOURCES = $(wildcard *.c)
C_OBJ = $(addprefix $(OBJDIR), $(C_SOURCES:.c=.o))
S_SOURCES = $(wildcard *.s)
S_OBJ = $(addprefix $(OBJDIR), $(S_SOURCES:.s=.o))
OBJ = $(C_OBJ) $(S_OBJ)

all: $(EXE)

$(EXE) : $(OBJ)
    $(LD) $(LDFLAGS) -o $(EXE) $^

$(OBJDIR)%.o : %.c
    mkdir -p $(OBJDIR)
    $(CC) $(CFLAGS) -o "$@" -c $<

$(OBJDIR)%.o : %.s
    mkdir -p $(OBJDIR)
    $(AS) $(ASFLAGS) -o "$@" $<


.PHONY: transfer clean dis emu
emu:
    fs-uae /home/apollo/src/amiga/base/dev13.fs-uae

transfer:
    scp $(EXE) apollo@samba.home.lan:/media/usb/ironwolf_4tb/dev/amiga/hd0/

dis:
    ira -BASEREG=4 -PREPROC $(EXE) $(OBJDIR)$(NAME).asm

clean:
    $(RM) -r $(OBJDIR)
output from IRA v2.09
Code:
[...]

    SECTION S_2,BSS

__BSSBAS:
    DS.L    1
_SysBase:
    DS.L    1
_DOSBase:
    DS.L    1
_GfxBase:
    DS.L    1
_IntBase:
    DS.L    1
_ThisTask:
    DS.L    1
_OldCopList:
    DS.L    1
_OldView:
    DS.L    1
_WBScreen:
    DS.L    1
_OldRes:
    DS.L    1
_OldIntenar:
    DS.L    1
_OldIntreqr:
    DS.L    1
_OldDmaconr:
    DS.L    1
_HasVBR:
    DS.L    1
_KickVersion:
    DS.L    1
    END
vbcc V0.9g
vlink V0.16d
vasm 1.8h
Apollo is offline  
Old 08 May 2021, 15:45   #2
vbc
Registered User
 
Join Date: Jan 2021
Location: Germany
Posts: 3
Quote:
Originally Posted by Apollo View Post
hello,
currently I play around with some code in C and Asm using the vbcc/vlink/vasm family. To make it more interesting I am using the small code and small data model. Using the docs and some disassembling with IRA I came along quite quickly.

Originally I defined local variables in Assembler and C parts. Then I came aware that the startup code is only clearing the BSS content of vars from the C part so I 'moved' over all variables from the Assembler part to (global) C and XREF'ing them, no problem.
When using small-data you can put them in section "__MERGED",bss. That should work from assembly.
Quote:
Now I see that all variables get 'extended' to DS.L regardless of their original size. Of course this doesn't make a difference for the size of the executable but still I wonder did I make something wrong here?
vbccm68k tends to put global variables on 32bit boundaries. IRA probably cannot tell the difference between a 32bit variable and a 16bit variable followed by a gap.
vbc 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
gcc and 64 bit, long long ints, not behaving for me? Ernst Blofeld Coders. C/C++ 2 10 December 2020 12:58
vbcc bss clearing issue dalton Coders. C/C++ 3 02 December 2017 22:50
ASM in statements - accessing "shared" variables earok Coders. Blitz Basic 4 27 September 2017 06:52
Variables? Retro1234 Coders. Blitz Basic 12 15 March 2017 12:41
Towers (Warning, long shot and long post) Drake1009 Looking for a game name ? 2 13 May 2005 00:11

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 16:41.


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