Work with two data segments in TASM

I want to work with two data segments in my TASM program. I know this sucks, but I should have two fairly large arrays, each of which has the size FFFFh (and I would like them to be larger).

I WARNING segments as follows: assume cs:code, ds:data, ds:dat2, ss:stac. Before each use of the variable in any of the data segments, I wrote:

mov ax, data (or dat2)
mov ds, ax

Now, when I try to compile, I get the following error for each line in which I use the variable:

**Error** source.ASM(232) Can't address with currently ASSUMEd segment registers

In addition, I noticed that the error only occurs when the variable is accessed directly. When I write mov ax, example, I get an error message, but when I write mov ax, offset example, I do not get an error.

Is there any way to solve this? Or, better yet, not using two data segments?

Thanks!

+4
source share
1 answer

ASSUME- this is just information for assembler, it does not produce and does not change any code. You should insert it if the assembler complains, for example. d. "CS is not available from the current segment." You can override ASSUMEin every place of the source code, it is valid for the following lines.

Example:

.MODEL huge

_TEXT SEGMENT
ASSUME CS:_TEXT
start:
    mov ax, _DATA
    mov ds, ax

    lea dx, [txt1]
    mov ah, 09h
    int 21h

    mov ax, _DAT2
    mov ds, ax

    lea dx, [txt2]
    mov ah, 09h
    int 21h

    jmp far ptr far_away

_TEXT ENDS

_TEXT2 SEGMENT
ASSUME CS:_TEXT2
far_away:
    mov ax, _DAT3
    mov ds, ax

ASSUME DS:_DAT3
    mov dx, example
    mov ah, 02h
    int 21h
    xchg dh, dl
    int 21h
    mov dl, 13
    int 21h
    mov dl, 10
    int 21h

    lea dx, [txt3]
    mov ah, 09h
    int 21h

    mov ax, 4C00h
    int 21h
_TEXT2 ENDS

_DATA SEGMENT
ORG 0FF00h
    txt1 DB "TXT_1", 13, 10, '$'
_DATA ENDS

_DAT2 SEGMENT
ORG 0FF00h
    txt2 DB "TXT_2", 13, 10, '$'
_DAT2 ENDS

_DAT3 SEGMENT
ORG 0FF00h
    example DW 'ab'
    txt3 DB "TXT_3", 13, 10, '$'
_DAT3 ENDS

_STACK SEGMENT STACK 'STACK'
      DW  1000h dup(?)
_STACK ENDS

END start
+4
source

Source: https://habr.com/ru/post/1610550/


All Articles