K
KnowALittle
Guest
The following are different code fragments that are using .CODE and SEGMENT in the same listing and in some cases different results occur than the expected results. The name of all the listings are ASSEMBLY1.asm:
Case 1: no errors
.model medium
.code ;segments created are PUBLIC and alignment is WORD
mov ax,ax
ASSEMBLY1_TEXT segment ;segments created are PUBLIC and alignment is WORD. This is because .code created the initial definition for ASSEMBLY1_TEXT segment to be PUBLIC and the alignment to be WORD
ASSEMBLY1_TEXT ends
end
Case 2: Error occur, as it should
.model medium
.code ASSEMBLY1_TEXT ;segments created are PUBLIC and alignment is WORD.
mov ax,ax
ASSEMBLY1_TEXT segment PRIVATE ;A error occurs here because the .CODE directive created this segment as PUBLIC and a alignment of WORD and now you are attempting to change the combine type from PUBLIC to PRIVATE.
ASSEMBLY1_TEXT ends
end
CASE 3: NO error occurs BUG??
ASSEMBLY2_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.
ASSEMBLY2_TEXT ends
.model medium
.code ;existing segment named ASSEMBLY1_TEXT that is PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.
mov ax,ax
end
Case 4: no error, BUG??
ASSEMBLY2_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.
ASSEMBLY2_TEXT ends
.model medium
.code ; ;a segment named ASSEMBLY1_TEXT that was PRIVATE with a alignment of PARA is now changed to PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.
mov bx,bx
end
From the different testing of .CODE and SEGMENT I have determined when a .CODE directive is encountered ANY segments that are created by .CODE have a combine type of PUBLIC and a alignment of WORD. If a SEGMENT instruction is encountered and has no segment options defined then it creates a combine type of PRIVATE and an alignment of PARA.
I was expecting a .CODE directive to inherit the combine type and alignment where the original SEGEMENT instruction was first defined but that is not the case. Is this the way .CODE is suppose to work or is this a bug?
I was hoping to be able to define segments with options using the long form of SEGMENT and then use the .CODE and other directives. Does this not work?
I have not tried this yet for .DATA,.DATA?,.CONST,.FARDATA,.FARDATA? and .STACK. I expect the same result. Am I correct?
Thanks for any help, David
Continue reading...
Case 1: no errors
.model medium
.code ;segments created are PUBLIC and alignment is WORD
mov ax,ax
ASSEMBLY1_TEXT segment ;segments created are PUBLIC and alignment is WORD. This is because .code created the initial definition for ASSEMBLY1_TEXT segment to be PUBLIC and the alignment to be WORD
ASSEMBLY1_TEXT ends
end
Case 2: Error occur, as it should
.model medium
.code ASSEMBLY1_TEXT ;segments created are PUBLIC and alignment is WORD.
mov ax,ax
ASSEMBLY1_TEXT segment PRIVATE ;A error occurs here because the .CODE directive created this segment as PUBLIC and a alignment of WORD and now you are attempting to change the combine type from PUBLIC to PRIVATE.
ASSEMBLY1_TEXT ends
end
CASE 3: NO error occurs BUG??
ASSEMBLY2_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.
ASSEMBLY2_TEXT ends
.model medium
.code ;existing segment named ASSEMBLY1_TEXT that is PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.
mov ax,ax
end
Case 4: no error, BUG??
ASSEMBLY2_TEXT segment PRIVATE ;segments created are PRIVATE and alignment is PARA.
ASSEMBLY2_TEXT ends
.model medium
.code ; ;a segment named ASSEMBLY1_TEXT that was PRIVATE with a alignment of PARA is now changed to PUBLIC and alignment of WORD. No error is shown. A error should occur because the combine type and alignments do not match.
mov bx,bx
end
From the different testing of .CODE and SEGMENT I have determined when a .CODE directive is encountered ANY segments that are created by .CODE have a combine type of PUBLIC and a alignment of WORD. If a SEGMENT instruction is encountered and has no segment options defined then it creates a combine type of PRIVATE and an alignment of PARA.
I was expecting a .CODE directive to inherit the combine type and alignment where the original SEGEMENT instruction was first defined but that is not the case. Is this the way .CODE is suppose to work or is this a bug?
I was hoping to be able to define segments with options using the long form of SEGMENT and then use the .CODE and other directives. Does this not work?
I have not tried this yet for .DATA,.DATA?,.CONST,.FARDATA,.FARDATA? and .STACK. I expect the same result. Am I correct?
Thanks for any help, David
Continue reading...