Advertisement
Kyl38

Untitled

Aug 24th, 2023
1,529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASM (NASM) 1.08 KB | Source Code | 0 0
  1. [org 0x7c00]
  2. bits 16
  3.  
  4. start:
  5.  
  6.     inputLoop:
  7.         mov ah, 00h ;keyboard input is set to register ah
  8.         int 16h ;keyboard input is gotten
  9.         mov ah, 0x0e ;teletype interupt is set to print out al, in other words the keyboard input
  10.         int 0x10    ;teletype is told to output what ever is in ah to the screen
  11.         mov di, User_Input
  12.         cmp al, 'version'
  13.         je printVersion
  14.  
  15.         jmp inputLoop ; allows the user to enter command
  16.  
  17.  
  18.     printVersion:
  19.         mov si, version_string ; Sets the string as a source
  20.         call printFunction ; Calls the print function
  21.  
  22.  
  23. jmp $
  24.  
  25. version_string db 'Version: prealpha 0.0.0.1', 0  ;defines a string I want to output later.
  26. User_Input db '', 0
  27.  
  28. printFunction:   ; Credit to mikeos for this function.
  29.     mov ah, 0Eh     ; int 10h 'print char' function
  30.  
  31. .repeat:            ; Loop
  32.     lodsb           ; Get character from string
  33.     cmp al, 0
  34.     je .done        ; If char is zero, end of string
  35.     int 10h         ; Otherwise, print it
  36.     jmp .repeat
  37.  
  38. .done:
  39.     ret
  40.  
  41.  
  42.  
  43. ;
  44. ;   Magic boot number
  45. ;  
  46. times 510 - ($-$$) db 0
  47. dw 0xAA55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement