printing on nasm 64bit Linux machine - 64-bit

I'm trying to print out a float value without using printf
any ideas?
I know with printf I have to use xmm0 registers to pass the values through, but for integers i use general purpose registers....
ideas?

How about sprintf or snprintf? They output to a string.

Related

How do I convert '\x80' hex to decimal

I am communicating with a servo using python's serial module. When I perform a serial.read(1) I get the value '\x80'. I need to convert this to decimal (128). Any suggestions?
Oh, never mind. I should have thought a bit. Googling opposite of chr() found me this page in the python docs. And ord() does the trick.

Can you add two address registers in 68000 using ADDA

For example if I write "ADDA A1, A5" would this be valid?
Sure you can. That's what the instruction is good for.
Note you must put the .l postfix after the instruction if you want a full 32-bit addition. Without the postfix, the assembler will assume word (16-bit) size and add the sign-extended word source operand to the destination.

ASM (Gnu AS): How to split a FLOAT variable into parts?

I got a small problem: that I want to split a float variable into parts and then compute these parts (add / subtract etc.). My main problem is that I don't know how to get that splitted parts/variables from the float type variable. I want to operate on those parts using rax / eax registers and b,c,d etc.
Is there somebody who can help me to acquire some knowledge about this and eventually lead me to some code that can do the trick? One restriction of mine is: I can't operate on FPU commands.

Converting String to DWORD (Assembly x86)

I am trying to learn how to convert a string to an integer. I think I am pretty close. My code works for numbers under 260. Once the numbers entered are greater than or equal to 260, then it just converts them to 0. I think it might have something to do with the size of a BYTE, but I'm not sure how to fix it. Any suggestions?
Some Irvine functions are included, but I'm trying to write my own ReadInt function.
I can see the problem. Rather than giving away the answer completely, here's a hint:
The lodsb instruction loads one byte into al (which is the low 8 bits of eax). The rest of eax is unchanged. What might cause eax to contain extra bits that aren't changed by lodsb?

readint nasm linux assembly

Is there a way / system call / a function that lets me read numbers from stdin into a register?
currently I can read in a string of, say, 9 characters.
This is, unfortunately, not what I was looking for since my number could be of variable length (so long it is representable in assembly)
e.g. I want to be able to input "5" as well as "66785949" as well as negative numbers like "-1123534", and have it correctly represented as an actual number in assembly, not a string.
I've been looking everywhere so I decided to ask here.
If there's no easy way to do it, is it possible to use C's input/output function library into my linux nasm assembly code? How would I do that and how would I call one of these functions to get a number from stdin?
Thanks
No, there is no system call to do it. Yes, you can easily call atoi(), if you don't feel like implementing it yourself. You just need to link to the C library (-lc) and declare the external symbol (extern atoi).

Resources