The arm is at least honoring the 16 bit boundary, hopefully x86 takes care of that somewhere else. unsigned short fun ( unsigned short x )Ġ: 8d 87 00 10 00 00 lea 0x1000(%rdi),%eax mov r2, #1065353216 0x3f800000įloating point 1.0 single precision, just bitsĪs far as the notion that cisc vs risc treat things differently cisc uses smaller registers and cisc uses 32 or 64 bit. Here the bits we think of as an address are just bits being added. So ptr+1 is saved to ptr in memory (these are all bits to the processor notice how it doesnt know this is a pointer nor a signed pointer some of these bits are an address but only when the register is used as an address is it an address. ldr r12, 64 Īhh a missed optimization opportunity add r12,r2,#1 would have been much cheaper. for each ptr++ we have to save back to the global as it is global so r3 holds the address to ptr for the duration. It gets the address to ptr (global variable so at compile time it doesnt know where it is, so it has to leave a place it can reach for the linker to fill in, in other instruction sets same problem but the "location" is a immediate to the instruction and the instruction is incomplete until link time, but the space is left either way). ![]() It puts the address of ptr in a register (this is also optimized), it preps some of the constants. There is the academic "harvard architecture" but those really dont work well in the real world, modern processors are generally modified harvard as they use one main bus but tag transactions as instruction fetches or data cycles (so if you have an i cache vs d cache you can sort them).īits is bits, they have no meaning to the computer, only to the humans. ![]() There are no magic bits in the patterns to indicate data from instruciton. It is up to the programmer and compiler to not ask it to consume bits as instructions that are not instructions. Note the processor doesnt know instructions from data either, whatever is fed in is what it consumes as instructions. You will eventually find for example that on a 32 or 64 bit computer it is inefficient to try to save space and use 8 bit variables rather than 32 or 64 as the compiler has to add masking and sign extension for the folks that tend to use signed integers. Most of this is trivial to see if you disassemble your code for whatever language you are using. Now sometimes there are conversions that do matter, perhaps even the data one if the byte is not stored as a byte but is in a register, then if unsigned a sign extension has to happen. Now computer languages which are generally not computer friendly have lots of opinions about bits, this variable is this type and that variable is that type and in some languages if I want to "convert" 8 bits from one type to another an ascii character to a data byte I have to some kind of conversion which is of course dead code as there is no such thing as ascii nor a data byte in the processor. those fall out say into a register, and now we write those bits to the address we used before which is only an address for the one/few clock cycles it is sampled from a register and sent on its way.īyte, halfword, word, doubleword, etc transfers are driven by the instruction or other logic (a fetch is not done with instructions normally) on a read with modern 32 or 64 or so width busses the read is of the whole width and as it gets to the processor core the byte lanes of interest are stripped off, depends on the architecture and bus of course, writes for targets that accept bytes halfwords words will have some scheme either a bytemask indicating which lanes are valid (vs which lanes which are dont cares) or there will be a size in units of bytes and both sides agree to align those bytes on the bus in a certain way (bit lanes 0 to n-1 would make most sense but whatever they design). addition and subtraction dont know about unsigned vs signed so it is just bits. the alu does some math on those bits, for those few clock cycles those bits are operands. Those bits are sent to the alu with constant that pointer could be to a structure so ++ could be some number other than one, in either case, it is sent along as well, or in some architectures you have to load it into a register first. The pointer is just bits at some address which is just bits so you put some bits in a register then you do a read from those bits for that one clock cycle as those bits move toward the main bus(es) those bits are an address, some bits come back they are just bits, they go in a register. Processors/logic in general doesnt know one bit from another, that is primarily in the eyes of the user or programmer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |