assembly

How do Operating Systems prevent programs from accessing memory?

心已入冬 提交于 2021-02-08 19:16:17
问题 My understanding currently is, I can write an operating system in C I can write a program for that operating system in C When I write an operating system I can see all of the memory When I write a program the operating system hides memory from other programs from me. Whenever a program runs inside an OS it appears to the program as if the memory it is allocated is all the memory the computer has How does the CPU / OS achieve this? Is this something purely implemented on the software level? Or

How do Operating Systems prevent programs from accessing memory?

别等时光非礼了梦想. 提交于 2021-02-08 19:12:53
问题 My understanding currently is, I can write an operating system in C I can write a program for that operating system in C When I write an operating system I can see all of the memory When I write a program the operating system hides memory from other programs from me. Whenever a program runs inside an OS it appears to the program as if the memory it is allocated is all the memory the computer has How does the CPU / OS achieve this? Is this something purely implemented on the software level? Or

How do Operating Systems prevent programs from accessing memory?

百般思念 提交于 2021-02-08 19:05:54
问题 My understanding currently is, I can write an operating system in C I can write a program for that operating system in C When I write an operating system I can see all of the memory When I write a program the operating system hides memory from other programs from me. Whenever a program runs inside an OS it appears to the program as if the memory it is allocated is all the memory the computer has How does the CPU / OS achieve this? Is this something purely implemented on the software level? Or

How do Operating Systems prevent programs from accessing memory?

我怕爱的太早我们不能终老 提交于 2021-02-08 19:05:11
问题 My understanding currently is, I can write an operating system in C I can write a program for that operating system in C When I write an operating system I can see all of the memory When I write a program the operating system hides memory from other programs from me. Whenever a program runs inside an OS it appears to the program as if the memory it is allocated is all the memory the computer has How does the CPU / OS achieve this? Is this something purely implemented on the software level? Or

Understanding the auipc+jalr sequence used for function calls

本小妞迷上赌 提交于 2021-02-08 15:32:07
问题 I was trying to read RISC-V assembly generated by gcc and I found that gcc creates sequence of auipc + jalr for some function calls and I don't understand how it works. Here's a simple example. Consider the following C source file: unsigned long id(unsigned long x) { return x; } unsigned long add_one(unsigned long x) { return id(x)+1; } I compile it with gcc -O2 -fno-inline -c test.c and I get the following assembly code: $ objdump -d test.o test.o: file format elf64-littleriscv Disassembly

How safe is this swap w/o pushing registers?

这一生的挚爱 提交于 2021-02-08 15:18:30
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

How safe is this swap w/o pushing registers?

走远了吗. 提交于 2021-02-08 15:18:21
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

How safe is this swap w/o pushing registers?

守給你的承諾、 提交于 2021-02-08 15:17:18
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

How to write two bytes to a chunk of RAM repeatedly in Z80 asm

帅比萌擦擦* 提交于 2021-02-08 13:12:32
问题 I'm trying to write two bytes (color values) to the VRAM of my TI-84 Plus CE-T calculator, which uses the Zilog eZ80 CPU. The VRAM starts at 0xD40000 and is 0x25800 bytes long. The calculator has a built in syscall called MemSet , which fills a chunk of memory with one byte, but I want it to alternate between two different values and store these in memory. I tried using the following code: #include "includes\ti84pce.inc" .assume ADL=1 .org userMem-2 .db tExtTok,tAsm84CeCmp call _homeup call

How to calculate parity of a 32bits number in assembly?

半腔热情 提交于 2021-02-08 12:16:37
问题 I need to calculate the parity of a 32 bits number and return it. To do this I must use XOR, SHR,SETP(or similar) and movzx. Somebody have an idea ? 回答1: Many ways to do this, of course. If you decide to use the hardware parity flag, keep in mind that it only checks the low 8 bits. A solution using this approach might be to process your 32 bit input as four 8 bit values, and use XOR on the partial results: p(31:0) = p(31:24) ^ p(23:16) ^ p(15:8) ^ p(7:0) To get the 8 bit units, you can use