Home > Software engineering >  How can I run assembly code by bypassing the operating system?
How can I run assembly code by bypassing the operating system?

Time:10-07

First of all, I don't know about modern CPUs and operating systems. For this reason, I will explain my explanation over the intel 8085 processor. And of course, I would like you to imagine that there is an operating system that can run on the intel 8085.

we have such assembly code:

MVI A,16
MVI B,16

ADD B

HLT

This code is very simple. When this code runs, it does the following: It loads the number 16 into registers a and b of the intel 8085 processor. And then it adds the value of these two registers.

Of course, when we try to run this code in our operating system, most likely nothing will happen.

What I want to ask is: How can I run a code that does not contain any system calls (or anything operating system specific) on the operating system (by-passing the operating system)? And I don't want the operating system to crash while doing this.

CodePudding user response:

Clearly you are running an operating system so why not try it yourself?

Processors only know how to run their instruction set and there are countless programming languages you can use to generate those instructions, including assembly language.

so.c

int fun ( int );

int main ( void )
{
    return(fun(5));
}

fun.c

int fun ( int x )
{
    return(x 3);
}

./so.elf ; echo $?
8

so

objdump -d fun.o

fun.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <fun>:
   0:   8d 47 03                lea    0x3(%rdi),           
  • Related