2016-10-20 42 views
1

我几乎学习大会,并成功地解决了我的问题在打印here为什么我的装配打印不能在第26行之后打印字符?

现在我还有一个问题。

我使用emu8086。我有这个代码使用带背景色的空格字符以位为单位打印一个小图片。我设法使它每行打印图像,但是当它到达第26行时,它停止打印,并出现“错误中断”的错误。

任何人都可以帮助我。

这里是整个代码:

org 100h 

name "charchar" 


org 100h 

;buhok line 1 (Grey) 
mov ax,0B800h 
mov es,ax 
mov di,56;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

;buhok line 2 
mov ax,0B800h 
mov es,ax 
mov di,200;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,202;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,208;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,210;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,214;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2         

mov ax,0B800h 
mov es,ax 
mov di,216;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2  

mov ax,0B800h 
mov es,ax 
mov di,218;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,222;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2  

mov ax,0B800h 
mov es,ax 
mov di,226;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,230;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,047 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,234;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,047 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

;buhok line 3 
mov ax,0B800h 
mov es,ax 
mov di,352;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,354;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,356;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,358;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,360;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,362;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,364;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,366;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,092 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,368;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,370;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,372;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,374;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,376;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,378;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,382;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,384;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,386;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,179 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,388;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,47 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,390;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,47 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,392;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,47 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,394;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,47 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,396;<target_address = y*160 + x*2> ; es:di set up 
mov ah,00001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,47 ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

........ 

;line 26 Hand, Body blue 

mov ax,0B800h 
mov es,ax 
mov di,4172;<target_address = y*160 + x*2> ; es:di set up 
mov ah,10001000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,' ' ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 
mov al,' ' ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 
mov al,' ' ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 
mov al,' ' ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 

mov ax,0B800h 
mov es,ax 
mov di,4188;<target_address = y*160 + x*2> ; es:di set up 
mov ah,11101000b;<color_attribute_for_whole_string> 
; now the print by letter gets here 
mov al,' ' ; al = letter, ah = attribute (ax set up) 
stosw  ; [es:di] = ax, di += 2 



    mov dl,0 ;X (SCREEN COORDINATE). 
    mov dh,5 ;Y (SCREEN COORDINATE). 
    int 10h ;BIOS SCREEN SERVICES. 

;FINISH THE PROGRAM PROPERLY. 
    mov ax,4c00h 
    int 21h 

ret 
+0

@ Ped7g希望你也可以在这里帮忙 –

+1

历史上,PC上的文本模式限于25行。第26行(部分)在视频RAM内存范围之外。 Emu8086可能会认为这是一个段错误。顺便说一下,在接近结束时,您先调用“INT 10h”,而不先将“AH”设置为2。 –

+0

什么是80x25中的第26行?也许你想首先切换到其他文本模式更多的线?像80x50一样? https://en.wikipedia.org/wiki/VGA-compatible_text_mode#PC_common_text_modes ...在80x25“第26行”不存在,所以我不知道你想要达到什么。 – Ped7g

回答

3

给出了使用0B800h作为视频片段及使用EMU8086的,很明显,你的80x25字符界面上工作。该屏幕后面的视频RAM总共占用4000个字节。当您的程序在该区域以下(使用mov di,4172mov di,4188)寻址某个位置时,它会有效写入屏幕外。

如果你正在运行在一个真正的BIOS/DOS环境中,该代码,然后这些离屏写只想去多余的显示页面,但由于这是EMU8086这些额外的显示页面不存在。所以你不应该写这4000个字节。


正如@Ruud说你忘了指定在AH寄存器中的功能代码为的setCursor功能。

mov dl, 0 ;X (SCREEN COORDINATE). 
mov dh, 5 ;Y (SCREEN COORDINATE). 
mov ah, 2 
int 10h ;BIOS SetCursor. 

;line 26 Hand, Body blue 

既然你命名屏幕第一行线1,那你(试图)写此评论下面的线是相当线27

3840 -> 3999 line 25 
4000 -> 4159 line 26 
4160 -> 4319 line 27 <-- 4172 and 4188 belong here! 

mov ax,0B800h 
mov es,ax 

为什么你重复这些说明了这么多次?将ES段寄存器设置为正确的值后,它将保持设置为多于一个输出。

1

的主要问题是缺少最后int 10hah值。在这一点上是ah0xE8(从手/体蓝属性),和int 10h不具有这种功能。

而且清理你的符号位,描述问题时,想到等了一会儿您正在使用的号码,让我试着总结:

使用的文本模式有分辨率80x25个字符(你也可以尝试选择其他模式,VGA有几个)。

字符的地址是(y * 80 + x) * 2,其中y是[0,24]并且x是[0,79]。注意x/y的最大有效值是如何“大小-1”,而不是大小本身。所以已经y = 25会把你从屏幕的可见区域。

从这我希望你使用“行0”到“行24”,而不是“行1” - >“行25”,因为它是直接使用y值行描述。

但是,通过在VGA IBM PC上写入屏幕外区域通常是一种有效的操作,实际上,您可能会用VGA卡寄存器篡改(至少在真正的硬件上,不确定是否有emu8086)以移动视频内存的开始从B800:0000开始,创建“快速滚动”而不必为每个字符重写视频内存内容。这在你的例子中没有任何意义,因为你不会滚动屏幕(并且从你遇到的问题来看,我认为直接修改VGA控制寄存器对于你来说目前是一个高级话题)。


有在你的代码中的许多冗余的es设置只是其中之一(如Fifoernik说明)。

mov di,396;<target_address = y*160 + x*2> ; es:di set up海事组织也让你复杂化没有任何好处。

我不能自己尝试emu8086,但如果mov di,2*160 + 38*2不能编译,我会非常惊讶,这将允许你保持“[x,y]”对于人类阅读源文件是可见的(当然在反汇编时会有仅得到396的值,其被编译成输出的机器码)。 (我会惊讶到一个点,建议你沟渠emu8086和使用NASM + dosbox +一些DOS调试器,那个人也以非常体面的方式模拟VGA,包括许多控制寄存器,所以如果你想要重温直接设置图形卡的旧时代,大多数的VGA东西应该用DOSBox中工作,如果不是全部)

,并在例如下面的代码mov di,390 ... stosw后你做mov di,392,而di已经是392(你甚至有在stosw指令后注释)。您可以根据需要“链接”那些仅与更改ah和/或al交错的操作,以便在单行上写入连续字符。

也许你应该停下来一段时间来创建ASCII艺术,并在调试器中重复执行代码几次,并观察寄存器如何更改,并尝试更好地了解CPU的工作原理,这将为您节省一些时间,因为您将能够编写较短的代码(但要尽量保持可读性)。