[Help!] Use two different assembly symbol in D, but they are same address.

a11e99z black80 at bk.ru
Sat Aug 24 12:09:19 UTC 2019


On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote:
> Hi:
>   definition _vga_x and _vga_y symbol in asm, compile use nasm 
> -f elf64 -o boot.o boot.asm
>   [section .bss]
>     ...
>
>   [global _vga_x]
>   _vga_x:
>           resb 8
>   [global _vga_y]
>   _vga_y:
>           resb 8
>
>
>   and nm boot.o show below
>     ...
>    00107000 B _vga_x
>    00107008 B _vga_y
>
>  and In another D file use this two symbol
>
> extern(C) {
>  extern __gshared int _vga_x; //definition in boot.asm
>  extern __gshared int _vga_y; //definition in boot.asm
> }
>
>  void tt()
>  {
>     if (_vga_x == _vga_y)
>       //where is true, why?
>  }
>
>  but when a run tt so strange things happend that the test is 
> true.
>  Is where has a coding mistake.
>  src  https://github.com/lilijreey/OS-D

resb 8
just reserving 8 bytes not initializing it.
probably u compare some garbage. sometimes it equals, sometimes 
not.
no?



More information about the Digitalmars-d-learn mailing list