在DosBox中编译汇编程序时出错

时间:2017-01-05 20:07:42

标签: assembly x86 masm dosbox x86-16

我目前正在编译DosBox中的汇编程序,但我一直有些错误 有人可以帮我修理吗? 我附上了我在MASM和链接上收到的错误的屏幕截图。

enter image description here

这是我的代码:

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

1 个答案:

答案 0 :(得分:2)

MASM SEGMENT指令的签名如下:

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

因此,您的代码包含汇编程序提到的两个错误:

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

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

所以你在'ENDS'指令之前错过了各自的名字,就是这样。