如何在屏幕上打印字符

时间:2016-11-08 11:14:41

标签: assembly emu8086

我试着制作#'#'屏幕的左侧和另一侧将是' $'但它并没有停留在25 * 40

.MODEL TINY

.CODE

.STARTUP

  CLD
  MOV AX, 0B800H ;for open screen
  MOV ES, AX    
  MOV DI, 0
  MOV CX, 25*40  ;try to divide screen 
  MOV AX, 5C23H
  REP STOSW

  MOV AX, 0B800H
  MOV DS, AX
  MOV SI,0  
  MOV CX, 25*40
  MOV AX, 6F24H
  REP STOSW

.EXIT
END

1 个答案:

答案 0 :(得分:2)

.MODEL TINY

.CODE
.STARTUP

  CLD
  MOV AX, 0B800H ;for open screen
  MOV ES, AX
  XOR DI, DI     ; DI = 0
  MOV DX, 25     ; lines counter
line_loop:
  MOV CX, 40
  MOV AX, 5C23H
  REP STOSW
  MOV CX, 40
  MOV AX, 6F24H
  REP STOSW
  DEC DX
  JNZ line_loop

.EXIT
END

为了获得乐趣并为你练习xor的强大功能,可以使用更短的代码变体(尝试在调试器中跳过它或者理解其工作方式):

  ...
  XOR DI, DI     ; DI = 0
  MOV DX, 50     ; 50 half-lines to fill
  MOV AX, 5C23H  ; start with '#'
half_line_loop:
  MOV CX, 40
  REP STOSW
  XOR AX, 3307h  ; 5C23 xor 3307 = 6F24, 6F24 xor 3307 = 5C23
  DEC DX
  JNZ half_line_loop
  ...