Pepo Raev
Pepo Raev

Reputation: 25

Assembly bootloader loop dont enter the loop

this is a boot loader but i have a problem. it print Name,Course,Student_num and fav_movie. But im trying to print a line of "." but it prints only one dot. im not sure that i use the loop properly

[BITS 16]
[ORG 0x7C00]
top:
        ;; Put 0 into ds (data segment)
        ;; Can't do it directly
        mov ax,0x0000
        mov ds,ax
        mov cx, 10
        ;; si is the location relative to the data segment of the
        ;; string/char to display
        mov si, Name
        call writeString
        mov si ,Course
        call writeString
        mov si, Student_num
        call writeString
        mov si, fav_movie
        call writeString
        call repeat
        jmp $; Spin


repeat:
        mov dx, square
        mov bh,09h
        loop repeat
        int 21h

writeString:
        mov ah,0x0E ; Display a chacter (as before)
        mov bh,0x00
        mov bl,0x07
        mov di,si
        int 21h

nextchar:
        Lodsb ; Loads [SI] into AL and increases SI by one
        ;; Effectively "pumps" the string through AL
        cmp al,0 ; End of the string?
        jz done
        int 0x10 ; BIOS interrupt
        jmp nextchar

done:
        ret

Name db 'Petar',13,10,0 ; Null-terminated
Course db '1234',13,10,0
Student_num db '123456789',13,10,0
fav_movie db 'GoT',13,10,0
square db '.',13,10,0
    times 510-($-$$) db 0

        dw 0xAA55

enter image description here

Upvotes: 1

Views: 131

Answers (1)

Joshua
Joshua

Reputation: 43278

You are trying to call DOS APIs via int 21h from a boot sector. That's never gonna work.

You need to call int 10h instead.

AH = function code (0Ah) al = character bh = 0 (video page) cx = 1 (repetition count)

Upvotes: 2

Related Questions