首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EMU8086显示屏(黑屏)

EMU8086显示屏(黑屏)
EN

Stack Overflow用户
提问于 2018-05-11 18:47:39
回答 1查看 1.3K关注 0票数 3

我正在上微处理器课程,我的代码有问题。

我需要写一个程序代码,使一个词四处移动。

代码在(80*25)屏幕上正确工作(因为我的计算依赖于它)

但问题是:当我最大化显示屏幕时,一切都会出错!,因为尺寸改变了。

是否有任何指令代码,如果我们在代码中编写,强制显示包含相同的维度,即使我们最大化它?

25)

63)!

代码语言:javascript
复制
    mov ax, 0b800h

    mov ds, ax
    mov bx, 0 
    Main:    
    call dltru


    dltru:   ; diagonal left to right upper   
    mov bx,0
    mov si,0
    mov cx,21
    lower2:  
    call box         
    mov [bx+160+2+si],' '       
    mov [bx+160+4+si],'M'
    mov [bx+160+6+si],'O'
    mov [bx+160+8+si],'E'
    mov [bx+160+10+si],' '
    mov [bx+160+12+si],'S' 
    mov [bx+160+14+si],'A'       
    mov [bx+160+16+si],'Y'
    mov [bx+160+18+si],'E'
    mov [bx+160+20+si],'L'
    mov [bx+160+22+si],' '
    mov [bx+160+24+si],'F' 
    mov [bx+160+26+si],'A'
    mov [bx+160+28+si],'L'
    mov [bx+160+30+si],'A'
    mov [bx+160+32+si],'H'
    mov [bx+160+34+si],' '           
    call delete            
    add si,160
    add bx,6
    loop lower2    
    ret    


    Box: ;this will draw the box around the announcement!        
    ;left
    mov [0+bx+si],0B2h
    mov [160+bx+si],0B2h
    mov [320+bx+si],0B2h         
    ;right
    mov [36+bx+si],0B2h
    mov [196+bx+si],0B2h
    mov [356+bx+si],0B2h
;upper
mov [2+bx+si],0B2h
mov [4+bx+si],0B2h
mov [6+bx+si],0B2h 
mov [8+bx+si],0B2h
mov [10+bx+si],0B2h
mov [12+bx+si],0B2h  
mov [14+bx+si],0B2h
mov [16+bx+si],0B2h
mov [18+bx+si],0B2h 
mov [20+bx+si],0B2h
mov [22+bx+si],0B2h
mov [24+bx+si],0B2h 
mov [26+bx+si],0B2h
mov [28+bx+si],0B2h
mov [30+bx+si],0B2h
mov [32+bx+si],0B2h
mov [34+bx+si],0B2h       
;lower
mov [322+bx+si],0B2h
mov [324+bx+si],0B2h
mov [326+bx+si],0B2h 
mov [328+bx+si],0B2h
mov [330+bx+si],0B2h
mov [332+bx+si],0B2h  
mov [334+bx+si],0B2h
mov [336+bx+si],0B2h
mov [338+bx+si],0B2h  
mov [340+bx+si],0B2h 
mov [342+bx+si],0B2h
mov [344+bx+si],0B2h
mov [346+bx+si],0B2h
mov [348+bx+si],0B2h
mov [350+bx+si],0B2h
mov [352+bx+si],0B2h
mov [354+bx+si],0B2h       
ret


delete:  
mov [bx+162+si],' '
mov [bx+164+si],' '
mov [bx+166+si],' '
mov [bx+168+si],' '
mov [bx+170+si],' '
mov [bx+172+si],' '
mov [bx+174+si],' '
mov [bx+176+si],' '
mov [bx+178+si],' '
mov [bx+180+si],' '
mov [bx+182+si],' '
mov [bx+184+si],' '
mov [bx+186+si],' '
mov [bx+188+si],' '     
mov [bx+190+si],' '
mov [bx+192+si],' '
mov [bx+194+si],' '     
;left
mov [0+bx+si],' '
mov [160+bx+si],' '
mov [320+bx+si],' '         
;right
mov [36+bx+si],' '
mov [196+bx+si],' '
mov [356+bx+si],' '
;upper
mov [2+bx+si],' '
mov [4+bx+si],' '
mov [6+bx+si],' ' 
mov [8+bx+si],' '
mov [10+bx+si],' '
mov [12+bx+si],' '  
mov [14+bx+si],' '
mov [16+bx+si],' '
mov [18+bx+si],' ' 
mov [20+bx+si],' '
mov [22+bx+si],' '
mov [24+bx+si],' ' 
mov [26+bx+si],' '
mov [28+bx+si],' '
mov [30+bx+si],' '
mov [32+bx+si],' '
mov [34+bx+si],' '       
;lower
mov [322+bx+si],' '
mov [324+bx+si],' '
mov [326+bx+si],' ' 
mov [328+bx+si],' '
mov [330+bx+si],' '
mov [332+bx+si],' '  
mov [334+bx+si],' '
mov [336+bx+si],' '
mov [338+bx+si],' '  
mov [340+bx+si],' ' 
mov [342+bx+si],' '
mov [344+bx+si],' '
mov [346+bx+si],' '
mov [348+bx+si],' '
mov [350+bx+si],' '
mov [352+bx+si],' '
mov [354+bx+si],' '       
ret
EN

回答 1

Stack Overflow用户

发布于 2018-05-17 10:53:03

mov bx+160+2+si,‘’

由于固定值为160 (仅对80列屏幕有效),您的代码在可选分辨率上失败。

您需要的是计算文本视频内存中1条scanline的大小:

。首先查找当前屏幕上的实际列数。BIOS在0040h:004Ah的内存变量中有此计数。

。然后加倍这个值,因为在视频内存中,每个字符/属性占用两个字节。

。最后,使用此值而不是固定值160。

代码语言:javascript
复制
push ds
mov  bx, 0040h
mov  ds, bx
mov  bx, [004Ah]
shl  bx, 1     ; This gives: BX=160 if 80x25, BX=382 if 191x63
pop  ds

在屏幕的第二行写入内容如下:

代码语言:javascript
复制
mov  [bx+2+si],' '       
mov  [bx+4+si],'M'
mov  [bx+6+si],'O'
mov  [bx+8+si],'E'

在屏幕的第三行写入内容如下:

代码语言:javascript
复制
add  bx, bx
mov  [bx+2+si],0B2h
mov  [bx+4+si],0B2h
mov  [bx+6+si],0B2h 
mov  [bx+8+si],0B2h
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50298504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档