* remove "\r" nonsense
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / baremetal0.5.2 / programs / argtest.asm
blobf9abf388ca419e351fa5c39d350cf5dd02134813
1 ; Argument Test Program (v1.0, July 6 2010)
2 ; Written by Ian Seyler
4 ; BareMetal compile:
5 ; nasm argtest.asm -o argtest.app
8 [BITS 64]
9 [ORG 0x0000000000200000]
11 %INCLUDE "bmdev.asm"
13 start: ; Start of program label
15 call b_get_argc ; Get the number of arguments that were passed
16 cmp al, 1 ; Was the number 1?
17 je noargs ; If so then bail out. The first argument is the program name
18 mov rsi, hello_message ; Load RSI with memory address of string
19 call b_print_string ; Print the string that RSI points to
20 mov al, 1 ; Argument values start at 0 so we want the second one
21 call b_get_argv ; Set RSI to point to the second argument
22 call b_print_string ; Print the string
23 call b_print_newline ; Print a new line
24 jmp fin ; Skip to the end
26 noargs:
27 mov rsi, noargs_message ; Print the error message
28 call b_print_string
30 fin:
32 ret ; Return to OS
34 hello_message: db 'Hello, ', 0
35 noargs_message: db 'Abort: No arguments supplied.', 13, 0