Advertisement
vasilev5

Untitled

Feb 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [BITS 16]
  2. [ORG 0x7C00]
  3.  
  4. ;Program that prints a square, student details and favourite movie.
  5.  
  6. top:
  7.     ;; Put 0 into ds (data segment)
  8.     ;; Can't do it directly
  9.     mov ax,0x0000
  10.     mov ds,ax
  11.     ;; si is the location relative to the data segment of the
  12.     ;; string/char to display
  13.  
  14.  
  15.     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.
  16.                 ;which will indicate the the string has ended at which point the next string will be printed in the same way.
  17.     call writeString ;Calls the writeString function.
  18.     mov si, eightSquareDots ;Repeats the same procedure as the one above.
  19.     call writeString
  20.     mov si, eightSquareDots
  21.     call writeString
  22.     mov si, eightSquareDots
  23.     call writeString
  24.     mov si, eightSquareDots
  25.     call writeString
  26.     mov si, eightSquareDots
  27.     call writeString
  28.     mov si, eightSquareDots
  29.     call writeString
  30.     mov si, eightSquareDots
  31.     call writeString
  32.  
  33.     mov si, studentName    ;studentName variable.
  34.     call writeString ; the writeString function prints the variable to the terminal.
  35.     mov si, studentCourse ;studentCourse variable.
  36.     call writeString ; Performs the same action as above.
  37.     mov si, favouriteMovie ;favouriteMovie variable.
  38.     call writeString ; Performs the same action as above.
  39.     jmp $ ; Spin
  40. writeString:
  41.     mov ah,0x0E ; Display a chacter (as before)
  42.     mov bh,0x00
  43.     mov bl,0x07
  44. nextchar:
  45.     Lodsb ; Loads [SI] into AL and increases SI by one
  46.     ;; Effectively "pumps" the string through AL
  47.     cmp al,0 ; End of the string?
  48.     jz done
  49.     int 0x10 ; BIOS interrupt
  50.     jmp nextchar
  51. done:
  52.     ret
  53.     ;This section of code contains the variables used to print text on the screen.
  54.     studentName db 'Name:  Martin Vasilev' ,13,10,0 ;Null - terminated
  55.     studentCourse db 'Course: Computer Science' ,13,10,0 ;Null -terminated
  56.     favouriteMovie db 'Favourite Movie: Ex Machina' ,13,10,0 ;Null -terminated
  57.     eightSquareDots db '........' ,13,10,0 ;Null - terminated
  58.     times 510-($-$$) db 0
  59.     dw 0xAA55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement