Even if you change the code, the previously executed value continues to appear.

Asked 2 years ago, Updated 2 years ago, 129 views

 INCLUDE Irvine32.inc
.data
str1 BYTE "Color output is easy!",0
.code
main PROC
    mov eax, yellow + (blue * 16)
    call SetTextColor
    mov edx, OFFSET str1
    call WriteString
    call Crlf
exit
main ENDP
END main

Color output is easy!

It comes out like this, and even if you change yellow to red, the color does not work as red, but it comes out as yellow continuously.

assembly asm

2022-09-21 18:41

1 Answers

I changed some colors and it works well.

If you can't change the color as you want, you should ask the author of the library who created SetTextColor.

He's a famous assembly book author.

Crlf Proto      ; output carriage - return / linefeed
WriteString Proto       ; write null - terminated string to output
SetTextColor Proto      ; set console text color

Delay Proto
black        = 0000b
blue         = 0001b
green        = 0010b
cyan         = 0011b
red          = 0100b
magenta      = 0101b
brown        = 0110b
lightGray    = 0111b
gray         = 1000b
lightBlue    = 1001b
lightGreen   = 1010b
lightCyan    = 1011b
lightRed     = 1100b
lightMagenta = 1101b
yellow       = 1110b
white        = 1111B

.Const

.Data?

.Data
    str1 Byte "Color output is easy!", 0

hInst       HINSTANCE   NULL


.Code

start:
    Invoke GetModuleHandle, NULL
    Mov hInst, Eax

    Mov Eax, lightRed + (lightGreen * 16)
    Call SetTextColor
    Mov Edx, Offset str1
    call WriteString
    Call Crlf
    Mov Eax, 5000 ; 5 seconds 
    Call Delay; for confirmation of results
    Invoke ExitProcess, 0
End start


2022-09-21 18:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.