flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > To print on terminal

Author
Thread Post new topic Reply to topic
C.H.R



Joined: 28 Jul 2017
Posts: 5
Location: Colombia
C.H.R 07 Dec 2017, 10:10
Hello

Actually I try to make a little dbg on MeOS, (im begginner) at first, I wanna to start a process from terminal. Ez task, but I want to print a number on terminal (processID), after to print buffer or string.

Code:
buffer:
    db "Process launched succesfully", 10,13
    db "PID: ",0
buffer_end:

....
code
....

mov rax, 256           ; syscall to start process
mov rbx, filename
mov rcx, 0
syscall

cmp rax, 0
jnz   errr
mov [debugee_pid], rbx

mov rdx, buffer
mov r8,  buffer_end - buffer
call send_line_to_terminal

    


How to match the buffer and pid. I dont know how to do.
To convert pid to ascii? How to do it ?

Someone that can help me.

Where to search more info about debuggers ?

thanks in advance...Sorry my bad english.
Post 07 Dec 2017, 10:10
View user's profile Send private message Send e-mail Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 312
Ville 12 Dec 2017, 17:25
You need to convert the number one character at a time into a string and then send it to terminal. Just devide the number by ten, add ascii base ( 48 ) to the remainder in dl (rdx), write dl into a position in string, and repeat until there is no integer part left in rax. Then send the string to the terminal. See the DIV instruction.
Post 12 Dec 2017, 17:25
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 20 Dec 2017, 22:37
Programming - System function calls

Quote:

Menuet 64 v1.26.80 system calls

rax : function number
int 0x60 : system call

47 - Display number

47 - Display number

In : rbx - bits 00-07 - 0 - rcx is number
- 1 - rcx is pointer
bits 08-15 - 0 - display decimal
- 1 - display hexadecimal
- 2 - display binary
bits 16-31 - number of digits to display
bits 32-63 - not used
rcx - Number or pointer
rdx - X shl 32 + Y
rsi - Color

Out: -
Post 20 Dec 2017, 22:37
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.