0

我尝试在屏幕左侧制作“#”,另一边是“$”,但它不会在 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
4

1 回答 1

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
  ...
于 2016-11-08T12:57:48.043 回答