alexfru / SmallerC

Simple C compiler
BSD 2-Clause "Simplified" License
1.4k stars 156 forks source link

DOS: how to get segment address #16

Closed ricardoquesada closed 7 years ago

ricardoquesada commented 7 years ago

context: developing a DOS 16-bit program. Using nasm + smlrl.

when using nasm -fobj I can do this:

section .data
...
section .code
  mov ax, data
  mov ds, ax

but when using nasm -felf (needed for smalrl) that code doesn't compile. The error code is: `error: symbol 'data' undefinied'

My question is, how can I access the .data segment in when using -felf. I know this is not strictly a smlrl issue, but smlrl is forcing me to using -felf. Thanks!

alexfru commented 7 years ago

In the small memory model it is expected that ds=ss. ss is set up before your program starts. Just copy it to ds. See srclib/c0ds.asm, srclib/dpstub.asm.

ricardoquesada commented 7 years ago

thanks.