Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [BITS 16]
- [ORG 0x7C00]
- ;Program that prints a square, student details and favourite movie.
- top:
- ;; Put 0 into ds (data segment)
- ;; Can't do it directly
- mov ax,0x0000
- mov ds,ax
- ;; si is the location relative to the data segment of the
- ;; string/char to display
- mov si, eightSquareDots ;Moves the eightSquareDots string into the system input and continues to read one character at a time into the buffer until it encounters a null cahracter.
- ;which will indicate the the string has ended at which point the next string will be printed in the same way.
- call writeString ;Calls the writeString function.
- mov si, eightSquareDots ;Repeats the same procedure as the one above.
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, eightSquareDots
- call writeString
- mov si, studentName ;studentName variable.
- call writeString ; the writeString function prints the variable to the terminal.
- mov si, studentCourse ;studentCourse variable.
- call writeString ; Performs the same action as above.
- mov si, favouriteMovie ;favouriteMovie variable.
- call writeString ; Performs the same action as above.
- jmp $ ; Spin
- writeString:
- mov ah,0x0E ; Display a chacter (as before)
- mov bh,0x00
- mov bl,0x07
- 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
- ;This section of code contains the variables used to print text on the screen.
- studentName db 'Name: Martin Vasilev' ,13,10,0 ;Null - terminated
- studentCourse db 'Course: Computer Science' ,13,10,0 ;Null -terminated
- favouriteMovie db 'Favourite Movie: Ex Machina' ,13,10,0 ;Null -terminated
- eightSquareDots db '........' ,13,10,0 ;Null - terminated
- times 510-($-$$) db 0
- dw 0xAA55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement