0

I expect this program to print lines of * to the console many times over before printing a line of =. Then, I expect it to pause, print pause, then repeat. Instead, the program is triggering on the line jg c3 every time and as a result is simply printing "pause" after each sleep and then repeating. But, if I change the line, cmp word [counter], 0xF000 to cmp word [counter], 0xF it works as expected. Why would this happen?

global Start
extern _GetStdHandle@4
extern _WriteFile@20
extern Sleep

STD_OUTPUT_HANDLE equ -11
STD_INPUT_HANDLE equ -10
NULL equ 0

section .data
counter dw 0

section .bss

section .text

Start:
    mov ebp, esp
    sub esp, 4
    ; hStdOut = GetstdHandle ( STD_OUTPUT_HANDLE)
Cont:
    push STD_OUTPUT_HANDLE
    call _GetStdHandle@4
    mov ebx, eax
    mov word [counter],0
write:
    inc word [counter]
    push 0
    lea eax, [ebp-4]
    push eax
    cmp word [counter], 0xF000
    je c2
    jg c3
c1:
    push (character_end-character)
    push character
    jmp do_write
c2:
    push (character2_end-character2)
    push character2
    jmp do_write
c3:
    push (character3_end-character3)
    push character3
    mov word [counter],0
    push 0x0F;0x5FF0
    call Sleep
    jmp do_write
do_write:
    push ebx
    call _WriteFile@20
start_again:
    jmp write
character:
    db '************************************************************************',0x0D,0x0A,NULL
character_end:
character2:
    db '=========================================================================',0x0D,0x0A,NULL
character2_end:
character3:
    db 'Pause',0x0D,0x0A,NULL
character3_end:
VCD_WL
  • 30
  • 11

0 Answers0