Skip to content

Tag: assembly

C assembler function casting

I came across this piece of code (for the whole program see this page, see the program named “srop.c”). My question is regarding how func is used in the main method. I have only kept the code which I thought could be related. It is the line *ret = (int)func +4; that confuses me. There are three questions I have

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

the physical address of global descriptor table?

I’m reading the disassemble code of mit os’s kernel code. I think the kernel code should follow the same rule. I saw the instruction in the kernel that load the Global Descriptor Table is as follows: lgdtl 0x10f018 I know the lgdt takes the length of the GDT (16bit) and the address of the GDT (32bit) as the operand. However,

nasm assembly linux timer or sleep

I’m trying to find a way to make my code wait for two seconds before proceeding. I’m using nasm for Linux in protected mode, so I can only use int 80h. I found a syscall called “alarm” (27) and another called “pause” (29). However, when I try to use those, the program waits and finishes instead of continuing execution. I’ve

How to clear screen on protected mode

I’m using NASM for Linux and I’d like know how, in the protected mode, you can clear the screen. I found a solution using the int10h, but on the protected mode I can only use int80h. Thanks in advance. Answer You can write x1b[2J to the standard output so the terminal get cleared and fix the cursor position using x1b[H,

How to print a number in ARM assembly?

I am trying to print a number that I have stored. I’m not sure if I am close or way off. Any help would be appreciated though. Here is my code: It compiles and runs, but I don’t see anything printed. From what I understand, I need the address of where to start printing in r1, how many bytes in