diff options
| -rw-r--r-- | c/tracker/main.c | 13 | ||||
| -rwxr-xr-x | c/tree/a.out | bin | 21088 -> 0 bytes | |||
| -rwxr-xr-x | nasm/helloworld.asm | 31 | ||||
| -rw-r--r-- | nasm/holamundo.asm | 10 | ||||
| -rw-r--r-- | nasm/triangle.asm | 33 | 
5 files changed, 70 insertions, 17 deletions
diff --git a/c/tracker/main.c b/c/tracker/main.c new file mode 100644 index 0000000..50ea362 --- /dev/null +++ b/c/tracker/main.c @@ -0,0 +1,13 @@ +/** + * @author      : garhve (dev@garhve.com) + * @file        : main + * @created     : Wednesday Dec 14, 2022 18:30:52 CST + */ + +#include <stdio.h> + +int main() +{ +    return 0; +} + diff --git a/c/tree/a.out b/c/tree/a.out Binary files differdeleted file mode 100755 index f07baa0..0000000 --- a/c/tree/a.out +++ /dev/null diff --git a/nasm/helloworld.asm b/nasm/helloworld.asm index 3016f58..48755fb 100755 --- a/nasm/helloworld.asm +++ b/nasm/helloworld.asm @@ -1,17 +1,14 @@ -SECTION .data -msg     db     "Hello World!", 0Ah  ; - -SECTION .text -global _start - -_start: - -        mov     edx, 13     ; number of bytes to write -        mov     ecx, msg    ; move memory address of 'msg' to ecx -        mov     ebx, 1      ; write to the file STDOUT -        mov     eax, 4      ; invoke SYS_WRITE (kernel opcode 4) -        int     80h - -        mov     ebx, 0      ; -        mov     eax, 1      ; -        int     80h +    global _start + +    section .text +_start:     mov rax, 1      ; system call for write +            mov rdi, 1      ; file handle 1 is stdout +            mov rsi, msg    ; address of string to output +            mov rdx, 13     ; number of bytes +            syscall         ; invoke operating system to do the write +            mov rax, 60     ; system call for exit +            xor rdi, rdi    ; exit code 0; +            syscall         ; invoke operating system to exit + +    section .data +msg         db  "hello, world",10       ; note the new line at end diff --git a/nasm/holamundo.asm b/nasm/holamundo.asm new file mode 100644 index 0000000..c7d3950 --- /dev/null +++ b/nasm/holamundo.asm @@ -0,0 +1,10 @@ +        global main +        extern puts +        section .text +main: +        mov  rdi, message +        call puts +        ret + +message: +        db  "hola, mundo", 0 diff --git a/nasm/triangle.asm b/nasm/triangle.asm new file mode 100644 index 0000000..a7a443d --- /dev/null +++ b/nasm/triangle.asm @@ -0,0 +1,33 @@ +            global _start +            section .text +_start: +            mov rdx, output         ; rdx holds next byte's address to write +            mov r8,  1              ; initial line length +            mov r9,  0              ; number of stars written to line so far +_line: +            mov byte [rdx], '*'     ; write single star to memory at given address in rdx +            inc rdx                 ; increase rdx to next call to write +            inc r9                  ; count number so far on line +            cmp r9, r8              ; compare if stars number exceed line length +            jne _line               ; loop if not yet exceed +_linedone: +            mov byte [rdx], 10      ; newline +            inc rdx                 ; move rdx to next memory address +            inc r8                  ; increase line length +            mov r9, 0               ; reset stars number for new line +            cmp r8, maxlines        ; compare if reached max line +            jng _line               ; loop newline +_done: +            mov rax, 1              ; invoke system call for write +            mov rdi, 1              ; file handler 1 is stdout +            mov rsi, output         ; address of string to output +            mov rdx, datasize       ; number of bytes +            syscall                 ; invoke OS to write +            mov rax, 60             ; invoke system call for exit +            xor rdi, rdi            ; exit code 0 +            syscall                 ; invoke OS to exit + +            section .bss +maxlines:   equ     8 +datasize:   equ     44 +output:     resb    datasize  | 
