Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Watcom ASM + C puzzle, variable has conflicting addresses (Developers)

posted by bencollver Homepage, 31.12.2025, 23:25
(edited by bencollver on 01.01.2026, 16:47)

I am working on porting Paul Vojta's calvin editor from Turbo-C and A86 to Watcom. I am currently troubleshooting a puzzle related to the asm sources. The file vv.asm has a symbol named "activpg" for one byte that is initialized to 0

            public  activpg
    ...
    activpg db      0                ;active display page
    crspos  dw      450h, 0          ;offset, segment of cursor location
    scaninf db      7, 0             ;bottom scan line and (3=mono, 0=cga)
    vidseg  dw      0b800h           ;segment of video card
    old24   dw      0, 0             ;old INT 24 address
    ...
            mov bx, offset activpg
            mov bh, byte ptr [activpg]


I linked a large memory model executable v.exe

In the v.map memory map, the Segments section includes:

    Segment                Class         Group          Address          Size
    =======                =====         =====          =======          ====
    ...
    _NULL                  CODE          DGROUP         10fc:0000        00000020


And the Memory Map section includes:


    Address        Symbol
    =======        ======
   
    Module: VV.OBJ(C:\CALSRC24\vv.asm)
   
    10fc:0c4c      activpg


I opened v.exe in the Watcom Debugger.

I stepped through the program into ex_version(), into the first botputs(), and into writes(). After stepping through the instruction "mov bx, offset activpg", the CPU registers window shows BX is 0C4C and DS is 3461. Inspecting the memory at 3461:0C4C shows the expected byte 00.

    Memory (0x3461:0x0000)
    0x0C40: 9A 65 23 09 00 00 00 00 00 00 00 00 00 50 04 00
    0x0C50: 00 07 00 00 B8 00 00 00 00 00 03 06 00 06 0B 00


After stepping through the instruction "mov bh, byte ptr [activpg]", the CPU registers window shows BX is 644C. I expected BX to be 004C.

Looking at Code->Assembly i see:

            mov bx, offset activpg
          mov    bx, 0C4C
            mov bh, byte ptr [activpg]
          mov    bh, byte ptr 027C


Inspecting the memory at 3461:027C shows the unexpected byte 64.

Why would Watcom think "activpg" is at two different addresses? (3461:0C4C versus 3461:027C)

 

Complete thread:

Back to the forum
Board view  Mix view
23154 Postings in 2179 Threads, 404 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum