【问题标题】:Assembly 8086 : How to Make thanks with a loop and video memory大会 8086:如何通过循环和视频存储器表示感谢
【发布时间】:2018-11-20 20:25:42
【问题描述】:

我需要一个程序,在文本的左侧和右侧显示带有心形符号的“谢谢”,但心形为红色,文本为绿色。 我现在有这个代码:

mov ax, 0B800h
mov es, ax
mov di,spiazz
mov byte ptr es:[di+0], ' '
mov byte ptr es:[di+2], ' '
mov byte ptr es:[di+4], ' '
mov byte ptr es:[di+1], 20h
mov byte ptr es:[di+3], 70h
mov byte ptr es:[di+5], 40h

使用类似这样的代码,我需要显示“heart(symbol)Thanks heart(symbol)”; 但心为红色,文字为绿色。 提前谢谢你

【问题讨论】:

  • 您可以移动整个单词,而不是单独的字节。喜欢mov word ptr es:[di+2], (20h<<8) + ' '。这比 2 个单独的字节存储指令高效得多。
  • 感谢彼得·科德斯
  • 您在哪个部分遇到了问题?您已经知道如何存储到显存中。你想怎么做一个循环?你想从其他地方复制吗?如果您的数据是立即数,则不能循环,因为您需要在每条指令中存储不同的值。
  • 你能举个例子吗?
  • @PeterCordes 非常感谢

标签: assembly x86-16


【解决方案1】:

有很多方法可以实现这一点。以下是其中之一:

    mov  ax, 0B800h                ;Points to the 80x25 text screen
    mov  es, ax
    mov  di, (13-1)*160+(37-1)*2   ;Print At(37,13);    //Column 37, Row 13
    mov  si, msg
    cld                            ;This makes SI and DI move  f o r w a r d  as is needed
    mov  ax, 0403h                 ;AL=3 (heart character) AH=04h (RedOnBlack)
    push ax                        ;(1) Preserve on the stack
LL:
    stosw
    mov  ah, 02h                   ;GreenOnBlack
    lodsb
    cmp  al, 0                     ;Message was zero-terminated
    jne  LL                        ;Terminator not yet reached
    pop  ax                        ;(1) Restore from the stack
    stosw                          ;This outputs the second heart character

    ...

msg db 'Thanks', 0

请特别注意 cmets!不要只是复制粘贴。

【讨论】:

    猜你喜欢
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多