How can I convert from ascii to integer? The code is writing an ascii value, and I think that if I can add 48 to value. I can write, but I can’t print, a two-stage number “for example 53 or 156”. How can I print? Answer It’s usually best to think about a high level language version first. If the
Tag: x86
Getting digit instead of Ascii in nasm assembly intel x86
I’m trying to learn the basics of assembly but can’t get across on how to display results stored in memory. What I’m trying to do is get the dot product of the two list of numbers and display it on the screen. However, I keep getting random letters which I believe are hex representations of the real decimal value. How
Accessing errno.h in assembly language
I want to access errno present in errno.h in assembly language in order to handle errors of write function call. I found somewhere that make call to _error in assembly language for this purpose but it is throwing errors as : My assembly code : ExitNewShell.asm How to access errno in assembly language? Answer You’re making x86 Linux syscalls from
Printing an integer with x86 32-bit Linux sys_write (NASM)
I’m new to this forum. I have a little experience with high-level languages (really little). Nearly one month ago I thought it would be a good idea to see how assembly worked so after choosing nasm (IA-32) on linux I started learning from a tutorial. Now, after ending it, I tried to write a simple program where you get the
Allocate more than 2GB on the heap using c++ on a 32bit linux kernel
This seems to be a very common problem, but still I haven’t found a definite answer. I have access to a server which runs linux, has 16 GB of RAM and a 16-core (64bit) CPU (/proc/cpuinfo gives “Intel(R) Xeon(R) CPU E5520 @ 2.27GHz”). However, the kernel is 32bit (uname -m gives i686). Of course, I have no root access, so
How can I create a basic NASM Assembly (Linux) calculator to add two integers?
I had a go at it, and tried: Sorry about all the XOR instructions, I just wanted to make sure registers were cleared before I used them for a system call, I’m still learning assembly and not sure about what instructions will render a register empty. When I compile, link and run this I can enter the two integers only
Where do the `[stack]`, `[vdso]` and `[vsyscall]` mmaps come from?
Consider the following program targeting Linux x86_64: inf.s: Which is basically an infinite loop. If I link and strip this I get an ELF executable: In the ELF executable the first program header LOAD contains the map that accounts for the first of the entry in the above mmaps (a.out). (Even if I strip everying but this header and code
Clear screen in a Linux terminal using assembly?
Is there a way to clear the screen in a terminal window with nasm? By clear the screen, I mean emulate the Ctrl-L hotkey. Remove all text from the window. Answer In Bash: In C: How do I find the string:
Prohibit unaligned memory accesses on x86/x86_64
I want to emulate the system with prohibited unaligned memory accesses on the x86/x86_64. Is there some debugging tool or special mode to do this? I want to run many (CPU-intensive) tests on the several x86/x86_64 PCs when working with software (C/C++) designed for SPARC or some other similar CPU. But my access to Sparc is limited. As I know,
How do I get the interrupt vector number on Linux?
When I run “cat /proc/interrupts”, I can get the following: How can I get the interrupt number of “NMI” “LOC” “SPU” “PMI”, etc. Answer On x86 NMIs are always on interrupt vector 2. The number is hard-coded just as common exceptions (division by 0, page fault, etc). You can find this in the CPU documentation from Intel/AMD. If the APIC