diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-06-23 15:12:55 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-06-23 15:12:55 -0400 |
commit | 3b46e7ef1f4c3f364e75e780eff923ef146ee42c (patch) | |
tree | c1e08f6ec3925c9c57f2093d59ab7444de9e28ce /builtin_echo.asm | |
parent | 2362c3ae6b32c816c4febe9714847fa4d80e1ad5 (diff) | |
download | minos-3b46e7ef1f4c3f364e75e780eff923ef146ee42c.tar.gz |
Implement initial builtin commands
Diffstat (limited to 'builtin_echo.asm')
-rw-r--r-- | builtin_echo.asm | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/builtin_echo.asm b/builtin_echo.asm index 1b4af89..9cc1e9c 100644 --- a/builtin_echo.asm +++ b/builtin_echo.asm @@ -5,16 +5,25 @@ builtin_echo: push bp mov bp, sp - mov bx, word [bp + 4] - add bx, 2 - push word [bx] - push .msg_fmt - call printf - add sp, 2 * 2 + mov cx, word [bp + 4] ; argc + mov bx, word [bp + 6] ; argv - mov sp, bp - pop bp - ret - .msg_fmt db '%s\n', 0 + cmp cx, 0 ; if no arguments, return + jbe .return + + .output: ; print argv + push word [bx] + push .msg_fmt + call printf + add sp, 2 * 2 + add bx, 2 + dec cx + jne .output + + .return: + mov sp, bp + pop bp + ret + .msg_fmt db '%s ', 0 %endif |