English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. Language (http://eab.abime.net/forumdisplay.php?f=114)
-   -   vbcc - asm/c mix - variables in bss get extended to long (http://eab.abime.net/showthread.php?t=106804)

Apollo 01 May 2021 16:29

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

vbc 08 May 2021 15:45

Quote:

Originally Posted by Apollo (Post 1480506)
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.


All times are GMT +2. The time now is 18:52.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.04539 seconds with 11 queries