我需要编写汇编代码,用于存储在文本模式下在屏幕上写入的内容(在dosbox中),清除屏幕然后恢复以前写的内容,所以我编写了这段代码但它看起来并不像工作正常..谁能指出为什么?我会非常感激
PS:我还是个菜鸟
这是我的代码:
Dataseg segment
Data_seg dw 2000 dup(?)
Dataseg ends
Codeseg segment
Main PROC far
assume ds:Dataseg,cs:Codeseg,ss:stackseg
Mov ax,Data_seg
Mov es,ax
Mov ax,0b800h
Mov ds,ax
Mov cx,25*80 ;(rows)*cols-default for screen
Mov di,OFFSET Data_seg
Mov si,0
CLD ;autoincrement
Rep movsw
;now clearing the screen
Mov cx,25*80
Mov ax,0b800h
Mov es,ax
Mov ax,0720h
Mov di,0
Rep stosw
;now restoring the contents of the screen
Mov ax,Data_seg
Mov ds,ax
Mov cx,25*80
Mov di,0
Mov si,OFFSET Data_seg
Rep movsw
Mov Ah,4ch
Int 21h
Main endp
Codeseg ends
end Main
答案 0 :(得分:0)
您混淆了“数据集”(段名称)和“Data_seg”(变量名称)。 Mov ax,Data_seg
加载变量Data_seg
的偏移量,不该段。加载细分有两种选择:
Mov ax, SEG Data_seg ; Load the segment of variable Data_seg
或
Mov ax, Dataseg ; Load the segment called "Dataseg"
答案 1 :(得分:0)
替换:
Mov ax,Data_seg
Mov es,ax
Mov ax,0b800h
Mov ds,ax
Mov di,OFFSET Data_seg
Mov si,0
由:
push cs
pop es
mov di, OFFSET Data_seg
Mov ax,0b800h
Mov ds,ax
xor si, si ;set pointer to the beginning of the screen
替换:
Mov ax,Data_seg
Mov ds,ax
Mov cx,25*80
Mov di,0
Mov si,OFFSET Data_seg
Rep movsw
由:
push cs
pop ds
mov ax, 0b800h
mov es, ax
Mov cx,25*80
Mov di, 0
Mov si,OFFSET Data_seg
Rep movsw