How can I get user input in my assembly bootloader?How can I safely create a nested directory?Assembly: Using the Data Segment Register (DS)Using Jump and Compare in Assembly LanguageGetting a string to print via bios interruptShould I normalize the signs of my input when computing the average?Am I using the source index (si) correctly?Concatenate two given strings in 8086 + MOVSB does not workSnake Assembly 8086: not moving correctlySnake Game Assembly: increasing body length not workingHow to determine whether the computer has an XT/AT keyboard in assembly?
bash script: "*.jpg" expansion not working as expected inside $(...), for picking a random file
What ways have you found to get edits from non-LaTeX users?
How do governments keep track of their issued currency?
A curious prime counting approximation or just data overfitting?
Why was the Sega Genesis marketed as a 16-bit console?
SOQL Not Recognizing Field?
Impedance ratio vs. SWR
How to forge a multi-part weapon?
Is open-sourcing the code of a webapp not recommended?
How can I get an unreasonable manager to approve time off?
Passing multiple files through stdin (over ssh)
What's up with this leaf?
How can I tell the difference between unmarked sugar and stevia?
Taxi Services at Didcot
Why would future John risk sending back a T-800 to save his younger self?
1980s live-action movie where individually-coloured nations on clouds fight
Using "subway" as name for London Underground?
Should I give professor gift at the beginning of my PhD?
Project Euler #7 10001st prime in C++
Preventing employees from either switching to competitors or opening their own business
Difference between > and >> when used with a named pipe
When conversion from Integer to Single may lose precision
Why is one of Madera Municipal's runways labelled with only "R" on both sides?
Prime Sieve and brute force
How can I get user input in my assembly bootloader?
How can I safely create a nested directory?Assembly: Using the Data Segment Register (DS)Using Jump and Compare in Assembly LanguageGetting a string to print via bios interruptShould I normalize the signs of my input when computing the average?Am I using the source index (si) correctly?Concatenate two given strings in 8086 + MOVSB does not workSnake Assembly 8086: not moving correctlySnake Game Assembly: increasing body length not workingHow to determine whether the computer has an XT/AT keyboard in assembly?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm working on a assembly bootloader. I need help with getting input from the user. I use such code to print on the screen (in start
). In getInput
, I tried to get input from user but has not been worked. So, how could I do it?
org 0x7C00
BITS 16
start:
cli ; Disable interrupts
mov si, bootMsg1 ; Point SI to message
mov ah, 0x0E ; Indicate BIOS we're going to print chars
.loop lodsb ; Loads SI to AL
or al,al ; Checks if the end of string
jz seperate
or al,al
jz halt ; Jump to halt at the end
int 0x10 ; Otherwise, call interrupt for printing the char
jmp .loop ; Next iteration of loop
...
getInput:
cli
mov ah, 08 ; Indicate BIOS to get input
int 21h
mov ah,02
mov DL,AL
int 21h
MOV AH,4Ch ; Function to exit
MOV AL,00 ; Return 00
INT 21h
halt: hlt ; CPU command to halt the execution
bootMsg1: db "Slight Bootloader 1, Welcome!",13,10 ; Message
bootMsg2: db"------------",13,10
assembly operating-system kernel boot
add a comment |
I'm working on a assembly bootloader. I need help with getting input from the user. I use such code to print on the screen (in start
). In getInput
, I tried to get input from user but has not been worked. So, how could I do it?
org 0x7C00
BITS 16
start:
cli ; Disable interrupts
mov si, bootMsg1 ; Point SI to message
mov ah, 0x0E ; Indicate BIOS we're going to print chars
.loop lodsb ; Loads SI to AL
or al,al ; Checks if the end of string
jz seperate
or al,al
jz halt ; Jump to halt at the end
int 0x10 ; Otherwise, call interrupt for printing the char
jmp .loop ; Next iteration of loop
...
getInput:
cli
mov ah, 08 ; Indicate BIOS to get input
int 21h
mov ah,02
mov DL,AL
int 21h
MOV AH,4Ch ; Function to exit
MOV AL,00 ; Return 00
INT 21h
halt: hlt ; CPU command to halt the execution
bootMsg1: db "Slight Bootloader 1, Welcome!",13,10 ; Message
bootMsg2: db"------------",13,10
assembly operating-system kernel boot
2
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47
add a comment |
I'm working on a assembly bootloader. I need help with getting input from the user. I use such code to print on the screen (in start
). In getInput
, I tried to get input from user but has not been worked. So, how could I do it?
org 0x7C00
BITS 16
start:
cli ; Disable interrupts
mov si, bootMsg1 ; Point SI to message
mov ah, 0x0E ; Indicate BIOS we're going to print chars
.loop lodsb ; Loads SI to AL
or al,al ; Checks if the end of string
jz seperate
or al,al
jz halt ; Jump to halt at the end
int 0x10 ; Otherwise, call interrupt for printing the char
jmp .loop ; Next iteration of loop
...
getInput:
cli
mov ah, 08 ; Indicate BIOS to get input
int 21h
mov ah,02
mov DL,AL
int 21h
MOV AH,4Ch ; Function to exit
MOV AL,00 ; Return 00
INT 21h
halt: hlt ; CPU command to halt the execution
bootMsg1: db "Slight Bootloader 1, Welcome!",13,10 ; Message
bootMsg2: db"------------",13,10
assembly operating-system kernel boot
I'm working on a assembly bootloader. I need help with getting input from the user. I use such code to print on the screen (in start
). In getInput
, I tried to get input from user but has not been worked. So, how could I do it?
org 0x7C00
BITS 16
start:
cli ; Disable interrupts
mov si, bootMsg1 ; Point SI to message
mov ah, 0x0E ; Indicate BIOS we're going to print chars
.loop lodsb ; Loads SI to AL
or al,al ; Checks if the end of string
jz seperate
or al,al
jz halt ; Jump to halt at the end
int 0x10 ; Otherwise, call interrupt for printing the char
jmp .loop ; Next iteration of loop
...
getInput:
cli
mov ah, 08 ; Indicate BIOS to get input
int 21h
mov ah,02
mov DL,AL
int 21h
MOV AH,4Ch ; Function to exit
MOV AL,00 ; Return 00
INT 21h
halt: hlt ; CPU command to halt the execution
bootMsg1: db "Slight Bootloader 1, Welcome!",13,10 ; Message
bootMsg2: db"------------",13,10
assembly operating-system kernel boot
assembly operating-system kernel boot
edited Mar 24 at 17:07
Burak Yeniçeri
asked Dec 21 '18 at 10:10
Burak YeniçeriBurak Yeniçeri
5611
5611
2
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47
add a comment |
2
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47
2
2
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47
add a comment |
1 Answer
1
active
oldest
votes
Use Int 16h/AH=00h
.
Some output as Int 21h/AH=08h
.
Int 16h
has input utilities, Int 10h
has output (video) utilities.
Example.
Wait for the user to press a key and then "reboot".
BITS 16
xor ax, ax
int 16h
int 19h
TIMES 510 - ($-$$) db 0
dw 0aa55h
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrateint 16h/ah=00h
works.
– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeriint 16h/ah=00h
returns inax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.
– Margaret Bloom
Mar 17 at 13:09
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53882814%2fhow-can-i-get-user-input-in-my-assembly-bootloader%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use Int 16h/AH=00h
.
Some output as Int 21h/AH=08h
.
Int 16h
has input utilities, Int 10h
has output (video) utilities.
Example.
Wait for the user to press a key and then "reboot".
BITS 16
xor ax, ax
int 16h
int 19h
TIMES 510 - ($-$$) db 0
dw 0aa55h
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrateint 16h/ah=00h
works.
– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeriint 16h/ah=00h
returns inax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.
– Margaret Bloom
Mar 17 at 13:09
|
show 7 more comments
Use Int 16h/AH=00h
.
Some output as Int 21h/AH=08h
.
Int 16h
has input utilities, Int 10h
has output (video) utilities.
Example.
Wait for the user to press a key and then "reboot".
BITS 16
xor ax, ax
int 16h
int 19h
TIMES 510 - ($-$$) db 0
dw 0aa55h
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrateint 16h/ah=00h
works.
– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeriint 16h/ah=00h
returns inax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.
– Margaret Bloom
Mar 17 at 13:09
|
show 7 more comments
Use Int 16h/AH=00h
.
Some output as Int 21h/AH=08h
.
Int 16h
has input utilities, Int 10h
has output (video) utilities.
Example.
Wait for the user to press a key and then "reboot".
BITS 16
xor ax, ax
int 16h
int 19h
TIMES 510 - ($-$$) db 0
dw 0aa55h
Use Int 16h/AH=00h
.
Some output as Int 21h/AH=08h
.
Int 16h
has input utilities, Int 10h
has output (video) utilities.
Example.
Wait for the user to press a key and then "reboot".
BITS 16
xor ax, ax
int 16h
int 19h
TIMES 510 - ($-$$) db 0
dw 0aa55h
edited Dec 23 '18 at 18:29
answered Dec 21 '18 at 10:47
Margaret BloomMargaret Bloom
23.5k53271
23.5k53271
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrateint 16h/ah=00h
works.
– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeriint 16h/ah=00h
returns inax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.
– Margaret Bloom
Mar 17 at 13:09
|
show 7 more comments
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrateint 16h/ah=00h
works.
– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeriint 16h/ah=00h
returns inax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.
– Margaret Bloom
Mar 17 at 13:09
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Didn't work, how can I do it? Nothing happened again. Can you show me an example?
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
Note: I use VirtualBox o test and I captured keyboard/mouse with guest(so bootloader)
– Burak Yeniçeri
Dec 22 '18 at 16:30
2
2
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrate
int 16h/ah=00h
works.– Margaret Bloom
Dec 23 '18 at 18:31
@BurakYeniçeri See the updated answer for a minimal example. Tested with VirtualBox. Remember to setup your booting environment correctly, the example is only mean to demonstrate
int 16h/ah=00h
works.– Margaret Bloom
Dec 23 '18 at 18:31
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
I need another thing. I need to get which key did the user press. How can I get it as a string value?
– Burak Yeniçeri
Mar 16 at 15:42
@BurakYeniçeri
int 16h/ah=00h
returns in ax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.– Margaret Bloom
Mar 17 at 13:09
@BurakYeniçeri
int 16h/ah=00h
returns in ax
the scancode of the key and its translation in ASCII according to the bios keyboard layout. If you search this site you'll find plenty of examples.– Margaret Bloom
Mar 17 at 13:09
|
show 7 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53882814%2fhow-can-i-get-user-input-in-my-assembly-bootloader%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Int 21h is a DOS interrupt, which is only available if you run DOS. In a bootloader you are restricted to BIOS interrupts. See Ralf Brown's Interrupt List for a better approach.
– zx485
Dec 21 '18 at 10:27
If you are new to assembly, it might be easier to start with writing DOS programs because the API is richer and because the environment has less restrictions.
– fuz
Dec 21 '18 at 11:47