2012-01-29 5 views
0

안녕하세요, 그것은 특정 양의 문자 만 표시됩니다 nasm에 카운터를 추가하려고합니다.Nasm 운영 체제에 카운터가 있습니까?

나는 db에서 제거 할 수 있지만 16 비트 운영 체제 프로그래밍에 대해 더 배우고 싶습니다.

BITS 16 

start: 
    mov ax, 07C0h  ; Set up 4K stack space after this bootloader 
    add ax, 288  ; (4096 + 512)/16 bytes per paragraph 
    mov ss, ax 
    mov sp, 4096 

    mov ax, 07C0h  ; Set data segment to where we're loaded 
    mov ds, ax 


    mov si, text_string ; Put string position into SI 


    call print_string ; Call our string-printing routine 

    jmp $   ; Jump here - infinite loop! 


    text_string db 'Cyber Tronic Operating System version one', 0 


print_string:   ; Routine: output string in SI to screen 
    mov ah, 0Eh  ; int 10h 'print char' function 

.repeat: 
    lodsb   ; Get character from string 
    cmp al, 0 
       je .done 
    int 10h   ; Otherwise, print it 
    jmp .repeat 

.done: 
    ret 


    times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s 
    dw 0xAA55  ; The standard PC boot signature] 

답변

0

이처럼 "루프"명령을 사용하여

print_string:   ; Routine: output string in SI to screen 
    mov ah, 0Eh  ; int 10h 'print char' function 

    mov cx,characters_to_print 
.repeat: 
    lodsb   ; Get character from string 
    cmp al, 0 
       je .done 
    int 10h   ; Otherwise, print it 
    loop .repeat 

.done 
    ret 
관련 문제