如何打印汇编语言有色字符串? [英] How to print colored string in assembly language?

查看:322
本文介绍了如何打印汇编语言有色字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 扬DB一月$
串DB周日周一周二周三周四周五周六$
字符串1 DB1 2 3 $
字符串2分贝4 5 6 7 8 9 10 $
STRING3 DB11 12 13 14 15 16 17 $
串,DB18 19 20 21 22 23 24 $
STRING5 DB25 26 27 28 29 30 31 $


解决方案

code对于前景和背景色的所有组合:

 包括Irvine32.inc。数据STR1字节F,0DH,0AH,0;初始化字符(0DH,0AH下一行)前台双字? ;变量声明
背景双字?
应对双字?。code主要PROCMOV ECX,16;初始化ECX有16个L1:;外环
MOV柜台,ECX
MOV前景,ECX
十二月前景
MOV ECX,1612:;内环MOV背景,ECX
十二月底MOV EAX,背景;设置EAX =背景
SHL EAX,4;左移,相当于16乘以EAX
添加EAX,前景;添加前景到EAX调用settextcolor;设置前景色和背景色
MOV EDX,抵消STR1;字符串被移到EDX写作
电话writestring
环L;调用循环MOV ECX,计数器环L1
    出口
主要ENDP
主要END

Jan             db  "         January$          "     
string          db  "Sun Mon Tue Wed Thu Fri Sat$"
string1         db  "                 1   2   3$"
string2         db  " 4   5   6   7   8   9  10$"
string3         db  "11  12  13  14  15  16  17$"
string4         db  "18  19  20  21  22  23  24$"
string5         db  "25  26  27  28  29  30  31$"

解决方案

Code For All combinations of foreground and background colors:

Include Irvine32.inc

.data

str1 byte "F",0dh,0ah,0          ;character initialized (0dh,0ah for next line)

foreground Dword ?               ;variable declaration
background Dword ?
counter Dword ?

.code

main PROC

mov ecx,16                     ; initializing ecx with 16

l1:                             ;outer loop
mov counter,ecx
mov foreground,ecx
dec foreground
mov ecx,16



l2:                            ;inner loop

mov background , ecx
dec background

mov eax,background      ; Set EAX = background
shl eax,4               ; Shift left, equivalent to multiplying EAX by 16
add eax,foreground      ; Add foreground to EAX

call settextcolor       ;set foreground and background color


mov edx, offset str1    ; string is moved to edx for writing
call writestring


loop l2                  ;calling loop

mov ecx,counter

loop l1
    exit
main ENDP
END main

这篇关于如何打印汇编语言有色字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆