简体   繁体   中英

Error compiling assembler program in DosBox

I am currently compiling an assembler program in DosBox, but I keep getting some errors.
Can someone help me fix them?
I am attaching a screenshot with the errors I receive on MASM and link.

在此处输入图片说明

This is my code:

DATA SEGMENT 
  NUM1 DB ?
  NUM2 DB ?
  RESULT DB ?
  MSG1 DB 10,13,"ENTER FIRST NUMBER TO MULTIPLY : $"
  MSG2 DB 10,13,"ENTER SECOND NUMBER TO MULTIPLY : $"
  MSG3 DB 10 ,13,"RESULT OF MULTIPLICATION IS : $"
ENDS

CODE SEGMENT 
  ASSUME DS:DATA,CS:CODE
START:
  MOV AX,DATA
  MOV DS,AX

  LEA DX,MSG1
  MOV AH,9
  INT 21H 

  MOV AH,1 
  INT 21H
  SUB AL,30H 
  MOV NUM1,AL

  LEA DX,MSG2
  MOV AH,9
  INT 21H 

  MOV AH,1
  INT 21H
  SUB AL,30H
  MOV NUM2,AL

  MUL NUM1 

  MOV RESULT,AL
  AAM

  ADD AH,30H
  ADD AL,30H

  MOV BX,AX 

  LEA DX,MSG3 
  MOV AH,9
  INT 21H

  MOV AH,2
  MOV DL,BH
  INT 21H

  MOV AH,2
  MOV DL,BL
  INT 21H

  MOV AH,4CH
  INT 21H
ENDS
END START

The signature of the MASM SEGMENT directive is as follows:

name SEGMENT [[READONLY]] [[align]] [[combine]] [[use]] [[characteristics]] ALIAS(string) [['class']] 
  statements  
name ENDS 

So your code contains two errors which are mentioned by the assembler:

DATA SEGMENT 
  NUM1 DB ?
  ...
ENDS        ; This line should be: DATA ENDS

and

CODE SEGMENT 
  ASSUME DS:DATA,CS:CODE
  START:
  ...
ENDS        ; This line should be: CODE ENDS

So you were missing the respective names before the `ENDS' directives, that's all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM