machine-language

MIPS labels storage location

混江龙づ霸主 提交于 2019-12-04 20:59:48
In MIPS, while using a jump instruction, we use a label. again: nop $j again So when we reach the jump instruction, we use the label again to show where to go and the value of the actual address there is used. I wanted to know where the label again is stored. Meaning, say nop is stored at 0x00400000, and the jump instruction is at 0x00400004. Where, then is again kept, how does MIPS know again is pointing to 0x00400000? Is it stored in the Dynamic Data area of the memory map? This is the memory map I've been provided for MIPS I've also included the question which caused this confusion below,

Does a C/C++ program run the CPU or on the Kernel?

人盡茶涼 提交于 2019-12-04 15:01:49
I'm programming for quite some years now, but there's one thing that I never understood exactly: There are 2 types of programming languages. Compiled ones and interpreted ones, while compiled ones first need to be to compiled to a interpreted language, before they can be executed. For example, C/C++ needs to be compiled to machine language first, before it can be executed. And here comes my question: Who does actually run a compiled C/C++ Windows/Linux program? Is it interpreded by the CPU directly, or does the OS Kernel execute it and pass the commands to the CPU? And if the CPU executes it

PowerPC moving to variable SPR

依然范特西╮ 提交于 2019-12-04 11:40:00
I'm writing an assembly macro to a C-program, and being quite new with this I have gotten stuck on something. I'm trying to write a macro for moving data from a general purpose register to a special purpose register. My problem is that the syntax I've found to move data from a GPR to an SPR takes a constant SPR value, while I want to use a variable one stored in another register. # SPR is constant, rA is the value to be written mtspr SPR, rA I'm after something that looks like this: # rA contains the number of the SPR, and rB the value to be moved. AWESOMEmtspr rA, rB Is there a reason there

Help with 68k assembly - jump tables?

可紊 提交于 2019-12-04 00:31:56
I'm working on reverse engineering a large Amiga program in IDA, and I've made a ton of progress. However, there is some stuff I can't quite figure out. Namely, I have found several subroutines which use what I believe to be "jump tables" - but I can't quite figure out how they work. Does anyone have any advice? moveq #0,d0 move.b d7,d0 ; set D0 to a byte from CTRL subq.w #1,d0 ; subtract 1 from it blt.w finish_29ABA ; if D0 is less than 1, branch cmpi.w #$16,d0 bge.w finish_29ABA ; if D0 is greater than or equal to 16, branch add.w d0,d0 ; otherwise, double D0 move.w dword_29918(pc,d0.w),d0

6502 CPU Emulation

♀尐吖头ヾ 提交于 2019-12-03 05:12:00
问题 It's the weekend, so I relax from spending all week programming by writing a hobby project. I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below) I can manually run a series of operations in the debugger I wrote, but I'd like to load a NES rom and just point the program counter at its instructions, I figured that this would be the fastest way to find flawed opcodes. I wrote a quick NES rom loader

6502 CPU Emulation

℡╲_俬逩灬. 提交于 2019-12-02 18:43:06
It's the weekend, so I relax from spending all week programming by writing a hobby project. I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below) I can manually run a series of operations in the debugger I wrote, but I'd like to load a NES rom and just point the program counter at its instructions, I figured that this would be the fastest way to find flawed opcodes. I wrote a quick NES rom loader and loaded the ROM banks into the CPU memory. The problem is that I don't know how the opcodes are

Can someone tell me the very basics of how computer programming works? [closed]

被刻印的时光 ゝ 提交于 2019-11-29 20:44:31
What makes all the words of a programming language actually do anything? I mean, what's actually happening to make the computer know what all of those words mean? If I verbally tell my my computer to do something, it doesn't do it, because it doesn't understand. So how exactly can these human words written into a language actually cause the computer to do some desirable activity? Vinko Vrsalovic It all starts with the CPU or processor. Each processor type has a defined set of instructions it's able to perform. These instructions operate over ones and zeroes, which in turn represent whatever

How to call machine code stored in char array?

♀尐吖头ヾ 提交于 2019-11-29 19:58:37
I'm trying to call native machine-language code. Here's what I have so far (it gets a bus error): char prog[] = {'\xc3'}; // x86 ret instruction int main() { typedef double (*dfunc)(); dfunc d = (dfunc)(&prog[0]); (*d)(); return 0; } It does correctly call the function and it gets to the ret instruction. But when it tries to execute the ret instruction, it has a SIGBUS error. Is it because I'm executing code on a page that is not cleared for execution or something like that? So what am I doing wrong here? Horia Coman One first problem might be that the location where the prog data is stored is

zero out top 32 bits of 64-bit register

[亡魂溺海] 提交于 2019-11-29 07:24:18
Using amd64 assembly, whats the best way to zero out the top 32 bits of a 64-bit register, e.g. zero out the bits of rax that are not covered by eax? It appears that I cannot and the whole register against a 64-bit constant. movl %eax, %eax or mov eax, eax , depending on the assembler in use. see: Intel® 64 and IA-32 Architectures - Software Developer’s Manual, Volume 1 , 3.4.1.1 : General-Purpose Registers in 64-Bit Mode. 32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register. I should also add, in regards to @HansPassant's

Can someone tell me the very basics of how computer programming works? [closed]

久未见 提交于 2019-11-28 16:51:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . What makes all the words of a programming language actually do anything? I mean, what's actually happening to make the computer know what all of those words mean? If I verbally tell my my computer to do something, it doesn't do it, because it doesn't understand. So how exactly can