8-bit alignment

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
joaopa
Member
Posts: 46
Joined: Sat Mar 15, 2014 5:42 pm

8-bit alignment

Post by joaopa »

Hello

I would like to 8-bit align a label: Here is my test code that shows that there is a bug in z88dk

Code: Select all

#include <stdio.h> 

int main(void)
{
#asm
    org 5413h
ici:
    defs (7*(ici&7))&7
oula:
    defb 0
#endasm
}
The resulting map is

Code: Select all

NEED_ansiterminal               = $0001 ; const, local, , vg5k_crt0, , zcc_opt.def:3
DEFINED_CRT_ORG_CODE            = $0001 ; const, local, , vg5k_crt0, , zcc_opt.def:8
CRT_ORG_CODE                    = $4A20 ; const, local, , vg5k_crt0, , zcc_opt.def:9
TAR__clib_exit_stack_size       = $0020 ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:35
TAR__register_sp                = $FFFFFFFFFFFFFFFF ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:36
__register_sp                   = $FFFFFFFFFFFFFFFF ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_rules.inc:9
start                           = $4A20 ; addr, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:43
start1                          = $4A43 ; addr, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:78
crt0_init_bss                   = $4A48 ; addr, local, , vg5k_crt0, code_crt_init, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:13
CLIB_OPT_PRINTF                 = $FFFFFFFF801BF7BF ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:170
DEFINED_fputc_cons              = $0001 ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:334
DEFINED_puts_cons               = $0001 ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:335
ansipixels                      = $0100 ; const, local, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:348
CLIB_FOPEN_MAX                  = $000A ; const, local, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:137
ici                             = $5413 ; addr, local, , test, code_compiler, test.c:22
oula                            = $5413 ; addr, local, , test, code_compiler, test.c:24
i_4                             = $5422 ; addr, local, , closeall, code_compiler, closeall.c:31
i_2                             = $541C ; addr, local, , closeall, code_compiler, closeall.c:26
i_3                             = $544C ; addr, local, , closeall, code_compiler, closeall.c:60
i_5                             = $5449 ; addr, local, , closeall, code_compiler, closeall.c:58
i_6                             = $5449 ; addr, local, , closeall, code_compiler, closeall.c:57
fp_extra                        = $0004 ; const, local, , fclose, , fclose.c:20
fclose_inuse                    = $545F ; addr, local, , fclose, code_compiler, fclose.c:52
fclose_error                    = $545B ; addr, local, , fclose, code_compiler, fclose.c:49
fclose_success                  = $5490 ; addr, local, , fclose, code_compiler, fclose.c:90
fclose_no_net                   = $5480 ; addr, local, , fclose, code_compiler, fclose.c:76
fclose_check_success            = $548B ; addr, local, , fclose, code_compiler, fclose.c:84
show                            = $54B5 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:49
escvector                       = $5D0E ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:973
f_in_escape                     = $555B ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:238
f_escape                        = $556F ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:256
f_9b                            = $5584 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:275
noFF                            = $54D4 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:76
docls                           = $5540 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:192
loopn                           = $553A ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:177
isLF                            = $54DC ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:101
NoLF                            = $54E5 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:111
NoTAB                           = $5503 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:132
OutTAB                          = $54FF ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:128
NoBEL                           = $5510 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:144
NoBS                            = $5533 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:166
firstc                          = $5520 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:156
f_not_ANSI                      = $5533 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:171
f_loopdone                      = $553F ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:182
f_ANSI_exit                     = $5551 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:230
cur_parm_ptr                    = $5D10 ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:974
syntax_error                    = $5565 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:248
f_bracket                       = $557D ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:268
param_buffer                    = $5D14 ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:978
eat_key                         = $5D12 ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:975
f_get_args                      = $559F ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:294
fga_ignore                      = $55AA ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:303
get_param_B                     = $55C2 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:322
f_get_param                     = $55BF ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:318
fgp_may_quote                   = $55F0 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:354
param_end                       = $5D3C ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:979
NoBCinc                         = $55DA ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:340
f_in_param                      = $567D ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:462
fgp_isquote                     = $55F9 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:359
fgp_semi_or_cmd                 = $560E ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:370
string_term                     = $5D13 ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:976
f_get_string                    = $5635 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:403
fgp_cmd                         = $56B1 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:499
NoBCinc2                        = $5621 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:385
f_goto_next                     = $5623 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:390
fgs_init_next_param             = $5661 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:437
NoBCinc3                        = $564E ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:423
f_eat_semi                      = $5673 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:451
fgp_not_digit                   = $56AC ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:496
Per10                           = $5692 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:478
no_default                      = $56CA ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:524
no_m                            = $56E9 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:552
m_nodefault                     = $56DA ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:543
loop_m                          = $56DD ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:545
f_cmd_exit                      = $58FB ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:951
no_C                            = $5711 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:582
no_C_FWD                        = $5707 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:577
no_D                            = $5726 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:599
no_D_TOP                        = $5720 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:596
no_A                            = $573B ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:617
f_ansi_cup                      = $572D ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:609
no_A_TOP                        = $5735 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:614
no_B                            = $5758 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:638
B_ok                            = $5751 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:634
do_s                            = $5760 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:649
no_s                            = $576F ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:655
scp_x                           = $5D0C ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:971
scp_y                           = $5D0D ; addr, local, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:972
do_u                            = $5777 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:666
no_u                            = $5786 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:672
IsHVP                           = $578E ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:682
no_H                            = $57D1 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:728
H_Nodeflt                       = $579A ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:691
H_nodef1                        = $57A4 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:699
HLineOK                         = $57B8 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:712
HColOK                          = $57CB ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:725
is_J1_b                         = $5821 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:790
no_J                            = $585E ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:827
J_nodefault                     = $57E4 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:751
no_J_0                          = $581D ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:787
j0loop                          = $57F3 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:761
j0LineLoop                      = $580D ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:776
no_J_1                          = $5853 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:820
j1loop                          = $5829 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:796
j1LineLoop                      = $5845 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:812
is_K1_o                         = $5896 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:873
no_K                            = $58BF ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:894
K_nodefault                     = $5871 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:851
no_K_0                          = $5892 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:870
K0loop                          = $587C ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:858
no_K_1                          = $58B1 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:888
K1loop                          = $589A ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:876
noecl                           = $58CC ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:906
no_n                            = $58E5 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:925
n_nodefault                     = $58D6 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:918
no_L                            = $58F3 ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:938
no_MM                           = $58FB ; addr, local, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:948
vg5k_inverse                    = $5D3F ; addr, local, , f_ansi_attr, bss_clib, stdio/ansi/vg5k/f_ansi_attr.asm:25
noreset                         = $5951 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:40
nobold                          = $595E ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:47
dim                             = $5966 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:52
nodim                           = $596F ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:57
nounderline                     = $597C ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:64
noCunderline                    = $5989 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:71
noblink                         = $5996 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:78
nocblink                        = $59A3 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:85
noreverse                       = $59BA ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:98
attrswap                        = $59B1 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:93
noCreverse                      = $59C9 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:107
noinvis                         = $59E0 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:123
oldattr                         = $59DF ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:121
nocinvis                        = $59EB ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:129
nofore                          = $5A03 ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:145
noback                          = $5A1B ; addr, local, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:162
BEL_LENGHT                      = $5A1E ; addr, local, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:18
BEL_loop                        = $5A22 ; addr, local, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:21
BEL_jump                        = $5A2B ; addr, local, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:28
BEL_FREQ_1                      = $5A29 ; addr, local, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:26
BEL_FR_2                        = $5A32 ; addr, local, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:33
zrow                            = $5A50 ; addr, local, , f_ansi_char, code_clib, stdio/ansi/vg5k/f_ansi_char.asm:48
_ef9345                         = $5A67 ; addr, local, , f_ansi_char, code_clib, stdio/ansi/vg5k/f_ansi_char.asm:68
clsloop                         = $5A70 ; addr, local, , f_ansi_cls, code_clib, stdio/ansi/generic/f_ansi_cls.asm:25
rloop                           = $5A87 ; addr, local, , f_ansi_dline, code_clib, stdio/ansi/generic/f_ansi_dline.asm:37
COLUMNS                         = $0028 ; const, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:18
ROW                             = $5D40 ; addr, local, , f_ansi_scrollup, bss_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:21
COLUMN                          = $5D41 ; addr, local, , f_ansi_scrollup, bss_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:23
scloop                          = $5AA7 ; addr, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:35
charput                         = $5ACB ; addr, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:65
attrput                         = $5AD8 ; addr, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:75
isLF                            = $5B03 ; addr, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:107
zrow                            = $5AE8 ; addr, local, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:86
cleanup                         = $4A3B ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:67
l_dcal                          = $4A47 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:83
__CRT_KEY_DEL                   = $0008 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_rules.inc:31
__CRT_KEY_CAPS_LOCK             = $0006 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_rules.inc:38
__CPU_CLOCK                     = $3D0900 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/target/vg5k/classic/vg5k_crt0.asm:37
__clib_exit_stack_size          = $0020 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_rules.inc:20
fputc_cons                      = $54A8 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:336
puts_cons                       = $5932 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:337
_fputc_cons                     = $54A8 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:338
_puts_cons                      = $5932 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:339
ansicolumns                     = $0040 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:352
ansicharacter_pixelwidth        = $0004 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:372
ansifont                        = $5B20 ; addr, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:375
ansifont_is_packed              = $0001 ; const, public, , vg5k_crt0, , /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_runtime_selection.asm:376
__sgoioblk                      = $5CA0 ; addr, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:143
__sgoioblk_end                  = $5D04 ; addr, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:144
__FOPEN_MAX                     = $000A ; const, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:142
base_graphics                   = $5D04 ; addr, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:150
exitsp                          = $5D06 ; addr, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:152
exitcount                       = $5D08 ; addr, public, , vg5k_crt0, bss_crt, /home/david/z88dk/lib/config//../..//lib/crt/classic/crt_section.asm:153
_main                           = $5413 ; addr, public, , test, code_compiler, test.c:20
_closeall                       = $5415 ; addr, public, , closeall, code_compiler, closeall.c:22
closeall                        = $5415 ; addr, public, , closeall, code_compiler, closeall.c:20
fabandon                        = $549A ; addr, public, , fabandon, code_clib, fabandon.asm:8
_fabandon                       = $549A ; addr, public, , fabandon, code_clib, fabandon.asm:9
_fclose                         = $544E ; addr, public, , fclose, code_compiler, fclose.c:33
fclose                          = $544E ; addr, public, , fclose, code_compiler, fclose.c:31
close                           = $54A7 ; addr, public, , close, code_clib, close.asm:11
_close                          = $54A7 ; addr, public, , close, code_clib, close.asm:12
fputc_cons_ansi                 = $54A8 ; addr, public, , fputc_cons, code_clib, stdio/ansi/fputc_cons.asm:19
f_ansi                          = $54B2 ; addr, public, , f_ansi, code_clib, stdio/ansi/f_ansi.asm:44
_ansi_COLUMN                    = $5D09 ; addr, public, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:966
ansi_COLUMN                     = $5D09 ; addr, public, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:967
_ansi_ROW                       = $5D0A ; addr, public, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:968
ansi_ROW                        = $5D0A ; addr, public, , f_ansi, bss_clib, stdio/ansi/f_ansi.asm:969
ansi_LF                         = $5900 ; addr, public, , f_ansi_lf, code_clib, stdio/ansi/f_ansi_lf.asm:22
ansi_putc                       = $591A ; addr, public, , f_ansi_putc, code_clib, stdio/ansi/f_ansi_putc.asm:24
puts_cons_ansi                  = $5932 ; addr, public, , puts_cons, code_clib, stdio/ansi/puts_cons.asm:19
ansi_DSR6                       = $5947 ; addr, public, , f_ansi_dsr6, code_clib, stdio/ansi/f_ansi_dsr6.asm:17
ansi_attr                       = $5948 ; addr, public, , f_ansi_attr, code_clib, stdio/ansi/vg5k/f_ansi_attr.asm:34
vg5k_attr                       = $5D3E ; addr, public, , f_ansi_attr, bss_clib, stdio/ansi/vg5k/f_ansi_attr.asm:24
ansi_BEL                        = $5A1C ; addr, public, , f_ansi_bel, code_clib, stdio/ansi/vg5k/f_ansi_bel.asm:16
ansi_CHAR                       = $5A39 ; addr, public, , f_ansi_char, code_clib, stdio/ansi/vg5k/f_ansi_char.asm:32
text_cols                       = $5A37 ; addr, public, , f_ansi_char, code_clib, stdio/ansi/vg5k/f_ansi_char.asm:28
text_rows                       = $5A38 ; addr, public, , f_ansi_char, code_clib, stdio/ansi/vg5k/f_ansi_char.asm:29
ansi_cls                        = $5A6C ; addr, public, , f_ansi_cls, code_clib, stdio/ansi/generic/f_ansi_cls.asm:21
ansi_del_line                   = $5A7A ; addr, public, , f_ansi_dline, code_clib, stdio/ansi/generic/f_ansi_dline.asm:25
ansi_SCROLLUP                   = $5A9A ; addr, public, , f_ansi_scrollup, code_clib, stdio/ansi/vg5k/f_ansi_scrollup.asm:28
ansifont_f4pack                 = $5B20 ; addr, public, , ansifont_f4pack, rodata_clib, stdio/ansi/ansifont_f4pack.asm:7
l_jphl                          = $5B0F ; addr, public, , l_jphl, code_crt0_sccz80, crt0/l_jphl.asm:9
l_ult                           = $5B10 ; addr, public, , l_ult, code_crt0_sccz80, crt0/l_ult.asm:15
l_compare_result                = $5B1A ; addr, public, , l_compare_result, code_crt0_sccz80, crt0/l_compare_result.asm:4
__head                          = $4A20 ; const, public, def, , ,
__tail                          = $5D42 ; const, public, def, , ,
__size                          = $1322 ; const, public, def, , ,
__CODE_head                     = $4A48 ; const, public, def, , ,
__CODE_tail                     = $4A48 ; const, public, def, , ,
__CODE_size                     = $0000 ; const, public, def, , ,
__code_crt_init_head            = $4A48 ; const, public, def, , ,
__code_crt_init_tail            = $4A65 ; const, public, def, , ,
__code_crt_init_size            = $001D ; const, public, def, , ,
__code_crt_exit_head            = $4A65 ; const, public, def, , ,
__code_crt_exit_tail            = $4A66 ; const, public, def, , ,
__code_crt_exit_size            = $0001 ; const, public, def, , ,
__code_driver_head              = $4A66 ; const, public, def, , ,
__code_driver_tail              = $4A66 ; const, public, def, , ,
__code_driver_size              = $0000 ; const, public, def, , ,
__code_compiler_head            = $5413 ; const, public, def, , ,
__code_compiler_tail            = $549A ; const, public, def, , ,
__code_compiler_size            = $0087 ; const, public, def, , ,
__code_clib_head                = $549A ; const, public, def, , ,
__code_clib_tail                = $5B0F ; const, public, def, , ,
__code_clib_size                = $0675 ; const, public, def, , ,
__code_crt0_sccz80_head         = $5B0F ; const, public, def, , ,
__code_crt0_sccz80_tail         = $5B20 ; const, public, def, , ,
__code_crt0_sccz80_size         = $0011 ; const, public, def, , ,
__code_l_head                   = $5B20 ; const, public, def, , ,
__code_l_tail                   = $5B20 ; const, public, def, , ,
__code_l_size                   = $0000 ; const, public, def, , ,
__code_l_sdcc_head              = $5B20 ; const, public, def, , ,
__code_l_sdcc_tail              = $5B20 ; const, public, def, , ,
__code_l_sdcc_size              = $0000 ; const, public, def, , ,
__code_l_sccz80_head            = $5B20 ; const, public, def, , ,
__code_l_sccz80_tail            = $5B20 ; const, public, def, , ,
__code_l_sccz80_size            = $0000 ; const, public, def, , ,
__code_compress_zx7_head        = $5B20 ; const, public, def, , ,
__code_compress_zx7_tail        = $5B20 ; const, public, def, , ,
__code_compress_zx7_size        = $0000 ; const, public, def, , ,
__code_ctype_head               = $5B20 ; const, public, def, , ,
__code_ctype_tail               = $5B20 ; const, public, def, , ,
__code_ctype_size               = $0000 ; const, public, def, , ,
__code_esxdos_head              = $5B20 ; const, public, def, , ,
__code_esxdos_tail              = $5B20 ; const, public, def, , ,
__code_esxdos_size              = $0000 ; const, public, def, , ,
__code_fp_head                  = $5B20 ; const, public, def, , ,
__code_fp_tail                  = $5B20 ; const, public, def, , ,
__code_fp_size                  = $0000 ; const, public, def, , ,
__code_fp_math48_head           = $5B20 ; const, public, def, , ,
__code_fp_math48_tail           = $5B20 ; const, public, def, , ,
__code_fp_math48_size           = $0000 ; const, public, def, , ,
__code_math_head                = $5B20 ; const, public, def, , ,
__code_math_tail                = $5B20 ; const, public, def, , ,
__code_math_size                = $0000 ; const, public, def, , ,
__code_error_head               = $5B20 ; const, public, def, , ,
__code_error_tail               = $5B20 ; const, public, def, , ,
__code_error_size               = $0000 ; const, public, def, , ,
__code_stdlib_head              = $5B20 ; const, public, def, , ,
__code_stdlib_tail              = $5B20 ; const, public, def, , ,
__code_stdlib_size              = $0000 ; const, public, def, , ,
__code_string_head              = $5B20 ; const, public, def, , ,
__code_string_tail              = $5B20 ; const, public, def, , ,
__code_string_size              = $0000 ; const, public, def, , ,
__code_adt_b_array_head         = $5B20 ; const, public, def, , ,
__code_adt_b_array_tail         = $5B20 ; const, public, def, , ,
__code_adt_b_array_size         = $0000 ; const, public, def, , ,
__code_adt_b_vector_head        = $5B20 ; const, public, def, , ,
__code_adt_b_vector_tail        = $5B20 ; const, public, def, , ,
__code_adt_b_vector_size        = $0000 ; const, public, def, , ,
__code_adt_ba_priority_queue_head = $5B20 ; const, public, def, , ,
__code_adt_ba_priority_queue_tail = $5B20 ; const, public, def, , ,
__code_adt_ba_priority_queue_size = $0000 ; const, public, def, , ,
__code_adt_ba_stack_head        = $5B20 ; const, public, def, , ,
__code_adt_ba_stack_tail        = $5B20 ; const, public, def, , ,
__code_adt_ba_stack_size        = $0000 ; const, public, def, , ,
__code_adt_bv_priority_queue_head = $5B20 ; const, public, def, , ,
__code_adt_bv_priority_queue_tail = $5B20 ; const, public, def, , ,
__code_adt_bv_priority_queue_size = $0000 ; const, public, def, , ,
__code_adt_bv_stack_head        = $5B20 ; const, public, def, , ,
__code_adt_bv_stack_tail        = $5B20 ; const, public, def, , ,
__code_adt_bv_stack_size        = $0000 ; const, public, def, , ,
__code_adt_p_forward_list_head  = $5B20 ; const, public, def, , ,
__code_adt_p_forward_list_tail  = $5B20 ; const, public, def, , ,
__code_adt_p_forward_list_size  = $0000 ; const, public, def, , ,
__code_adt_p_forward_list_alt_head = $5B20 ; const, public, def, , ,
__code_adt_p_forward_list_alt_tail = $5B20 ; const, public, def, , ,
__code_adt_p_forward_list_alt_size = $0000 ; const, public, def, , ,
__code_adt_p_list_head          = $5B20 ; const, public, def, , ,
__code_adt_p_list_tail          = $5B20 ; const, public, def, , ,
__code_adt_p_list_size          = $0000 ; const, public, def, , ,
__code_adt_p_queue_head         = $5B20 ; const, public, def, , ,
__code_adt_p_queue_tail         = $5B20 ; const, public, def, , ,
__code_adt_p_queue_size         = $0000 ; const, public, def, , ,
__code_adt_p_stack_head         = $5B20 ; const, public, def, , ,
__code_adt_p_stack_tail         = $5B20 ; const, public, def, , ,
__code_adt_p_stack_size         = $0000 ; const, public, def, , ,
__code_adt_w_array_head         = $5B20 ; const, public, def, , ,
__code_adt_w_array_tail         = $5B20 ; const, public, def, , ,
__code_adt_w_array_size         = $0000 ; const, public, def, , ,
__code_adt_w_vector_head        = $5B20 ; const, public, def, , ,
__code_adt_w_vector_tail        = $5B20 ; const, public, def, , ,
__code_adt_w_vector_size        = $0000 ; const, public, def, , ,
__code_adt_wa_priority_queue_head = $5B20 ; const, public, def, , ,
__code_adt_wa_priority_queue_tail = $5B20 ; const, public, def, , ,
__code_adt_wa_priority_queue_size = $0000 ; const, public, def, , ,
__code_adt_wa_stack_head        = $5B20 ; const, public, def, , ,
__code_adt_wa_stack_tail        = $5B20 ; const, public, def, , ,
__code_adt_wa_stack_size        = $0000 ; const, public, def, , ,
__code_adt_wv_priority_queue_head = $5B20 ; const, public, def, , ,
__code_adt_wv_priority_queue_tail = $5B20 ; const, public, def, , ,
__code_adt_wv_priority_queue_size = $0000 ; const, public, def, , ,
__code_adt_wv_stack_head        = $5B20 ; const, public, def, , ,
__code_adt_wv_stack_tail        = $5B20 ; const, public, def, , ,
__code_adt_wv_stack_size        = $0000 ; const, public, def, , ,
__code_alloc_balloc_head        = $5B20 ; const, public, def, , ,
__code_alloc_balloc_tail        = $5B20 ; const, public, def, , ,
__code_alloc_balloc_size        = $0000 ; const, public, def, , ,
__code_alloc_obstack_head       = $5B20 ; const, public, def, , ,
__code_alloc_obstack_tail       = $5B20 ; const, public, def, , ,
__code_alloc_obstack_size       = $0000 ; const, public, def, , ,
__code_arch_head                = $5B20 ; const, public, def, , ,
__code_arch_tail                = $5B20 ; const, public, def, , ,
__code_arch_size                = $0000 ; const, public, def, , ,
__code_font_head                = $5B20 ; const, public, def, , ,
__code_font_tail                = $5B20 ; const, public, def, , ,
__code_font_size                = $0000 ; const, public, def, , ,
__code_font_fzx_head            = $5B20 ; const, public, def, , ,
__code_font_fzx_tail            = $5B20 ; const, public, def, , ,
__code_font_fzx_size            = $0000 ; const, public, def, , ,
__code_z80_head                 = $5B20 ; const, public, def, , ,
__code_z80_tail                 = $5B20 ; const, public, def, , ,
__code_z80_size                 = $0000 ; const, public, def, , ,
__code_user_head                = $5B20 ; const, public, def, , ,
__code_user_tail                = $5B20 ; const, public, def, , ,
__code_user_size                = $0000 ; const, public, def, , ,
__rodata_fp_head                = $5B20 ; const, public, def, , ,
__rodata_fp_tail                = $5B20 ; const, public, def, , ,
__rodata_fp_size                = $0000 ; const, public, def, , ,
__rodata_compiler_head          = $5B20 ; const, public, def, , ,
__rodata_compiler_tail          = $5B20 ; const, public, def, , ,
__rodata_compiler_size          = $0000 ; const, public, def, , ,
__rodata_clib_head              = $5B20 ; const, public, def, , ,
__rodata_clib_tail              = $5CA0 ; const, public, def, , ,
__rodata_clib_size              = $0180 ; const, public, def, , ,
__rodata_user_head              = $5CA0 ; const, public, def, , ,
__rodata_user_tail              = $5CA0 ; const, public, def, , ,
__rodata_user_size              = $0000 ; const, public, def, , ,
__rodata_font_head              = $5CA0 ; const, public, def, , ,
__rodata_font_tail              = $5CA0 ; const, public, def, , ,
__rodata_font_size              = $0000 ; const, public, def, , ,
__rodata_font_fzx_head          = $5CA0 ; const, public, def, , ,
__rodata_font_fzx_tail          = $5CA0 ; const, public, def, , ,
__rodata_font_fzx_size          = $0000 ; const, public, def, , ,
__rodata_font_4x8_head          = $5CA0 ; const, public, def, , ,
__rodata_font_4x8_tail          = $5CA0 ; const, public, def, , ,
__rodata_font_4x8_size          = $0000 ; const, public, def, , ,
__rodata_font_8x8_head          = $5CA0 ; const, public, def, , ,
__rodata_font_8x8_tail          = $5CA0 ; const, public, def, , ,
__rodata_font_8x8_size          = $0000 ; const, public, def, , ,
__ROMABLE_END_head              = $5CA0 ; const, public, def, , ,
__ROMABLE_END_tail              = $5CA0 ; const, public, def, , ,
__ROMABLE_END_size              = $0000 ; const, public, def, , ,
__DATA_head                     = $5CA0 ; const, public, def, , ,
__DATA_tail                     = $5CA0 ; const, public, def, , ,
__DATA_size                     = $0000 ; const, public, def, , ,
__smc_clib_head                 = $5CA0 ; const, public, def, , ,
__smc_clib_tail                 = $5CA0 ; const, public, def, , ,
__smc_clib_size                 = $0000 ; const, public, def, , ,
__smc_user_head                 = $5CA0 ; const, public, def, , ,
__smc_user_tail                 = $5CA0 ; const, public, def, , ,
__smc_user_size                 = $0000 ; const, public, def, , ,
__data_clib_head                = $5CA0 ; const, public, def, , ,
__data_clib_tail                = $5CA0 ; const, public, def, , ,
__data_clib_size                = $0000 ; const, public, def, , ,
__data_stdlib_head              = $5CA0 ; const, public, def, , ,
__data_stdlib_tail              = $5CA0 ; const, public, def, , ,
__data_stdlib_size              = $0000 ; const, public, def, , ,
__data_crt_head                 = $5CA0 ; const, public, def, , ,
__data_crt_tail                 = $5CA0 ; const, public, def, , ,
__data_crt_size                 = $0000 ; const, public, def, , ,
__data_compiler_head            = $5CA0 ; const, public, def, , ,
__data_compiler_tail            = $5CA0 ; const, public, def, , ,
__data_compiler_size            = $0000 ; const, public, def, , ,
__data_user_head                = $5CA0 ; const, public, def, , ,
__data_user_tail                = $5CA0 ; const, public, def, , ,
__data_user_size                = $0000 ; const, public, def, , ,
__data_alloc_balloc_head        = $5CA0 ; const, public, def, , ,
__data_alloc_balloc_tail        = $5CA0 ; const, public, def, , ,
__data_alloc_balloc_size        = $0000 ; const, public, def, , ,
__DATA_END_head                 = $5CA0 ; const, public, def, , ,
__DATA_END_tail                 = $5CA0 ; const, public, def, , ,
__DATA_END_size                 = $0000 ; const, public, def, , ,
__BSS_head                      = $5CA0 ; const, public, def, , ,
__BSS_tail                      = $5CA0 ; const, public, def, , ,
__BSS_size                      = $0000 ; const, public, def, , ,
__bss_fp_head                   = $5CA0 ; const, public, def, , ,
__bss_fp_tail                   = $5CA0 ; const, public, def, , ,
__bss_fp_size                   = $0000 ; const, public, def, , ,
__bss_error_head                = $5CA0 ; const, public, def, , ,
__bss_error_tail                = $5CA0 ; const, public, def, , ,
__bss_error_size                = $0000 ; const, public, def, , ,
__bss_crt_head                  = $5CA0 ; const, public, def, , ,
__bss_crt_tail                  = $5D09 ; const, public, def, , ,
__bss_crt_size                  = $0069 ; const, public, def, , ,
__bss_fardata_head              = $5D09 ; const, public, def, , ,
__bss_fardata_tail              = $5D09 ; const, public, def, , ,
__bss_fardata_size              = $0000 ; const, public, def, , ,
__bss_compiler_head             = $5D09 ; const, public, def, , ,
__bss_compiler_tail             = $5D09 ; const, public, def, , ,
__bss_compiler_size             = $0000 ; const, public, def, , ,
__bss_clib_head                 = $5D09 ; const, public, def, , ,
__bss_clib_tail                 = $5D42 ; const, public, def, , ,
__bss_clib_size                 = $0039 ; const, public, def, , ,
__bss_string_head               = $5D42 ; const, public, def, , ,
__bss_string_tail               = $5D42 ; const, public, def, , ,
__bss_string_size               = $0000 ; const, public, def, , ,
__bss_alloc_balloc_head         = $5D42 ; const, public, def, , ,
__bss_alloc_balloc_tail         = $5D42 ; const, public, def, , ,
__bss_alloc_balloc_size         = $0000 ; const, public, def, , ,
__bss_user_head                 = $5D42 ; const, public, def, , ,
__bss_user_tail                 = $5D42 ; const, public, def, , ,
__bss_user_size                 = $0000 ; const, public, def, , ,
__BSS_END_head                  = $5D42 ; const, public, def, , ,
__BSS_END_tail                  = $5D42 ; const, public, def, , ,
__BSS_END_size                  = $0000 ; const, public, def, , ,
One sees that the variable oula is not 8-bit aligned. Z88 did not take in account the defs directive. Do you know a way to 8-align?

Thanks in advance
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

There may issues going on with labels and operators defined in inlined asm when using sccz80 to compile as you identified in another bug report:
https://www.z88dk.org/forum/viewtopic.php?id=10496

As mentioned there, inlined org will break the final exectuable.

That out of the way, there are still problems with what you are trying to do.

z80asm is used as a linking assembler, meaning the assembler that generates code does not know the final address of things in memory. That determination is made by the linker (also z80asm) in a final step that puts together the binary. The assemble step will assemble to an object file which is almost a binary but with addresses unresolved. Once all asm input has been assembled to an object file, the link step places the object files in memory according to a memory map. It then patches all the unresolved addresses in the binary to form the final executable.

A defs directive is handled by the assembler - it must create space at that point. However, it does not know the final value of "ici" in your example because memory addresses are settled by a later linking step. What happens is "ici" as seen by the assembler is an offset in the current section in the current file. So some space will be there but it will be unrelated to the final address of "ici".

Instead you must use an align directive to tell the linker to put the right amount of space there.

Code: Select all

void main(void)
{
__asm
ici:
    align 8
oula:
    defb 0
__endasm;
}
However at this time, the align directive is being interpretted by the assembler so again the alignment will be applied to the local section offset (local pc) instead of done by the linker where the address is known.

The align directive is new and I will raise an issue at github to see if paulo can update this or if it has to wait for the next version of z80asm.

Instead what is done now is that the alignment is made a property of sections, which are the containers of code that the linker operates on. When an alignment is attached to a section and since the arrangements of sections in memory is the linker's responsibility, the linker is able to align the section (memory block) according to address.

In the newlib, aligned sections are defined as part of the memory map:

Code: Select all

section bss_align_256
align 256

section bss_align_128
align 128

section bss_align_64
align 64

section bss_align_32
align 32

section bss_align_16
align 16

section bss_align_8
align 8

section bss_align_4
align 4

section bss_align_2
align 2
So you'd assign variables to the appropriate section to get the desired alignment. There is still an open issue with this method too unfortunately.

Defining your own aligned section in memory will work. If you place a section at a specific address, you of course control the alignment of the section.

Code: Select all

SECTION MINE
org 0x8000

PUBLIC _oula

_oula:   ;; oula is at address 0x8000 so is 8-byte aligned

  defb 0

align 8

PUBLIC _also

_also:  ;; also is also 8-byte aligned because the align directive moves the pc in the current file forward from an 8-byte aligned local pc at oula

   defb 0
(the addition of a leading underscore makes it possible for c to see the variables with a suitable extern declaration, eg "extern unsigned char oula;" )

This would be stored in a separate asm file and it can be made part of the compile by adding the asm file to the compile line. It's always preferable to have asm in a separate asm file instead of inlining it as in the toy examples we're examining here. After a compile, because this section MINE is not part of the memory map supplied by z88dk, an additional binary will be output called "foo_MINE.bin". You must get this into memory somehow before starting your program as create-app will not put it into the generated executable. There are tools to assemble a complete memory image but what is appropriate depends on the target.

So, at the end of it, "align" will only work as expected if it is applied to a local pc whose real alignment in memory is known. In the last example, section MINE is known to start at address 0x8000 which is 8-byte aligned. "_oula" is placed at address 0x8000. Before the align directive, the local PC is 1 and the absolute address is 0x8001. The align directive operates on "1" and adds 7 bytes of padding to move forward the local PC to 8 and the absolute address to 0x8008. As you can see, align works in this context because the requirements for alignment of the local PC match the requirements for alignment of the absolute address known in this file.

The solution used in the newlib where alignment properties are attached to sections will also work once a known bug is cleared. In this case, the memory map defines aligned sections in memory that the linker guarantees will be aligned when the sections are placed. The user assigns his data to the appropriate aligned section like this:

Code: Select all

section bss_align_8

PUBLIC _oula:

   defb 0

align 8
Anything assigned to these sections is part of the defined memory map and will be part of the final executable. The last "align 8" is needed to make sure another file that places something into this aligned section will also be aligned (data from another file would append to data declared here so the align is needed to ensure alignment is maintained).

The classic lib does not have these sections defined yet.

Longer term, align will be fixed so that it will be the linker's job to pad rather than the assembler's. However this is something that may have to wait for version 2 of z80asm.
abacaxi
New member
Posts: 1
Joined: Tue Nov 26, 2024 5:39 pm

Re: 8-bit alignment

Post by abacaxi »

Hi, new user here but long time machine coder on the spectrum and various embedded systems. I'm struggling with this very thing, I rely on aligned data in my code but when building an app in z88dk the linker couldn't care less. Any news, it's an old thread after all?
User avatar
dom
Well known member
Posts: 2239
Joined: Sun Jul 15, 2007 10:01 pm

Re: 8-bit alignment

Post by dom »

Paulo (who looks after the assembler/linker) tends not to come to the forum, so you should get a better answer over on GitHub.

From my perspective, I've not added aligned sections to classic so I've not experimented with this at all.
Timmy
Well known member
Posts: 418
Joined: Sat Mar 10, 2012 4:18 pm

Re: 8-bit alignment

Post by Timmy »

I must say that after writing code for so many years in z88dk, that I do not see this as a problem at all any more.

It is one of the main annoyances when using this linker, where you can never depend on the exact location of all your data.

But that can be mitigated easily, and I don't ever see much performance drop nor much code size increase when avoiding the problem.

It also has its advantages; it's so much easier writing for multiple architectures. Because every system has their own internal memory layout, you can't really depend on a fixed memory layout when writing for multiple machines anyway.

In the end, this helped me immensely when I had to port my games to other architectures later on.

On the other hand, if you are purely dealing with the zx machines, then there are specific tricks (solutions) for it.
Post Reply