user9507446
user9507446

Reputation: 401

Assembly program compilation error

I have a problem with following 16-bit TASM program which evaluates the expression (ab+cd)/(a-d):

MyCode          SEGMENT     

            ORG      100h
            ASSUME  CS:SEGMENT MyCode, DS:SEGMENT MyCode, SS:SEGMENT

Start:
            jmp      Beginning

a               DB      20
b               EQU     10
c               DW      5
d               =       3
Result          DB      ?

Beginning:
            mov     al, a    
            mov     bl, b    
            mov     dx,ax    
            mov     al, BYTE PTR c    
            mov     bl, d    
            mul     bl        
            add     dx,ax   
            mov     al, a     
            sub     al,bl    
            mov     bl,al    
            mov     ax,dx    
            div     bl        

            mov     Result, al 

            mov     ax, 4C00h
            int     21h

MyCode          ENDS

            END Start

The compilation errors I get in DOSBox console state that there's an undefined symbol (SEGMENT) and that the compiler can't address with currently ASSUMEd segment registers. It seems to me that that I'm missing the definition of a block, but I have no idea how to proceed further. What's wrong with this code?

Upvotes: 2

Views: 427

Answers (2)

Wilson Bautista
Wilson Bautista

Reputation: 1

L1: .model small L2: .stack L3: .data L4: printStr db "Pangasinan State University" L5: .code L6: BEGIN: L7: mov dx,OFFSET printString
L8: mov ax,SEG printStr
L9: mov ds,ax
L10: mov ah,9H
L11: int 21H
L12: mov ah, 4ch
L13: int 21D
L14: END BEGIN

Upvotes: 0

Michael Petch
Michael Petch

Reputation: 47613

I won't fix the logical errors for you, but the syntax in the top of this code is incorrect:

MyCode          SEGMENT     

            ORG      100h
            ASSUME  CS:SEGMENT MyCode, DS:SEGMENT MyCode, SS:SEGMENT

Start:

You don't use the directive SEGMENT in the assume, they have to be removed. When removed the segments have to have a name applied to them. One is missing on SS:. It should look like:

MyCode          SEGMENT

            ASSUME  CS:MyCode, DS:MyCode, SS:MyCode
            ORG      100h

Start:

In DOS COM program all the segments for DATA, CODE, and the STACK are in the same segment. You can also achieve the same by replacing it with:

.model tiny
.code
ORG 100h
Start:

The TINY model is designed to work for DOS COM program creation. The ORG 100h directive has to be preceded by the .code directive. With this modification you have to remove this line:

MyCode          ENDS

Upvotes: 1

Related Questions