View Single Post
Old 01 May 2021, 16:29   #1
Apollo
Registered User
 
Apollo's Avatar
 
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 137
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  
 
Page generated in 0.06866 seconds with 11 queries