I have minimize cost of calculating modulus in C.
say I have a number x and n is the number which will divide x
when n == 65536 (which happens to be 2^16):
mod = x % n (11 assembly instructions as produced by GCC)
or
mod = x & 0xffff which is equal to mod = x & 65535 (4 assembly instructions)
so, GCC doesn't optimize it to this ...
(If your lazy see bottom for TL;DR)
Hello, I am planning to build a new (prototype) project dealing with physical computing. Basically, I have wires. These wires all need to have their voltage read at the same time. More than a few hundred microseconds difference between the readings of each wire will completely screw it up. The Arduino...
Are there any PIC microcontroller programmers here?
I'm learning some PIC microcontroller programming using a pickit2 and the 16F690 chip that came with it. I'm working through trying out the various facilities at the moment. I can sucessfully read a byte from the EEPROM in code if I set the EEPROM vaklue in MPLAB but I don't seem to be...
I have checked the assembler options of GNU assembler as and I didn't find an option to specify the output object file format. If I am using the following command
as -o foobar.o foobar.s
What object file format will I get?
The as manual says that "The GNU as can be configured to produce several alternative object file formats." But h...
Hello,
A while back I was following some tutorials an assembly. I was running it all on a windows machine, compiling with NASM and then writing the compiled code to a floppy disk, then reboot and try the code. This process was long and time consuming and sadly was not on a mac. When I found out that Xcode for mac installed NASM I immedi...
I'm studying the Intel's IA-32 software developer manual. In particular, I'm reading the following manual: http://www.intel.com/Assets/PDF/manual/253666.pdf. Let's take for example the ADD instruction. On page 79 it is written that you can add an r8 (8-bit register) to an r/m8 (8-bit register or memory location). A few rows below, it is ...
Hello,
I was just wondering what other CPU architectures are available other than INTEL & AMD. So, found List of CPU architectures on Wikipedia.
It categorizes notable CPU architectures into following categories.
Embedded CPU architectures
Microcomputer CPU architectures
Workstation/Server CPU architectures
Mini/Mainframe CPU archite...
Hello, I am currently studying for an exam I'll have on x86 assembly.
I didn't have much luck googling for ":", too common of a punctuation mark :/
IDIV - Signed Integer Division
Usage: IDIV src
Modifies flags: (AF,CF,OF,PF,SF,ZF undefined)
Signed binary division of accumulator by source. If source is a
byte va...
I've got as far as telling VC++ to generate ASM files during compilation, which I never really used before. But it seems quite limited, like they are just extra files thrown out during the compilation.
I'd thought maybe the ASM/C++ code might be linked, so I can jump from C++ directly to the generated ASM code? Or could set breakpoints i...
I'm looking at textbooks for an undergraduate course in machine-level programming. If the perfect book existed, this is what it would look like:
Uses examples written in C or assembly language, or both.
Covers machine-level operations such as two's-complement integer arithmetic, bitwise operations, and floating-point arithmetic.
Expla...
I want to emulate windows programs (not VM, true emulation) under windows. This would require the emulator to make calls back to the system APIs, but the program itself would be emulated. The reason is I want to change the opcode formats for research purposes.
The process should be:
Take existing program.
Disassemble and then reassemb...
The dis module can be effectively used to disassemble Python methods, functions and classes into low-level interpreter instructions.
I know that dis information can be used for:
1. Find race condition in programs that use threads
2. Find possible optimizations
From your experience, do you know any other scenarios where Disassembly Pyth...
I'm trying to make a really simple spinlock mutex in C and for some reason I'm getting cases where two threads are getting the lock at the same time, which shouldn't be possible. It's running on a multiprocessor system which may be why there's a problem. Any ideas why it's not working?
void mutexLock(mutex_t *mutexlock, pid_t owner)
{
i...
Hello,
recently I've been reading some SO archives and encountered statements against x86 architecture.
http://stackoverflow.com/questions/2667256/why-do-we-need-different-cpu-architecture-for-server-mini-mainframe-mixed-cor
says "PC architecture is a mess, any
OS developer would tell you that."
http://stackoverflow.com/qu...
Hi,
I'm using ".align 16 \n\t" in some inline ARM assembly that is implementing some loops
to align it on a 16 byte boundary however gcc asm compiler is complaining that alignement
is too large
i want to implement -falign-loops=16 in asm for a particular loop
Thanks
...
I'm studying 8086 assembly language at high school and I have this question:
For example I have this number ABCD (hex). How is it stored on the memory?
Does the AB go for example to memory address 01 and the CD goes to address 02?
...
Hi,
I am just trying to implement multi-precision arithmetic on native MIPS. Assume that
one 64-bit integer is in register $12 and $13 and another is in registers $14 and $15.
The sum is to be placed in registers $10 and $11. The most significant word of the 64-bit integer is found in the even-numbered registers, and the least significa...
It seems to be a mainstream opinion that assembly programming takes longer and is more difficult to program in than a higher level language such as C. Therefore it seems to be recommend or assumed that it is better to write in a higher level language for these reasons and for the reason of better portability.
Recently I've been writing ...
Hi!
Can COM program be 32 bit?
How can I compile COM program?
I have TLINK32 and TASM32.
tasm32 \t alex_7.asm
pause
tlink32 alex_7.obj
pause
td32 main.exe
I ve got following error:
Fatal: 16 bit segments not supported in module alex_7.asm
I have DOSBOX and I'am running Windows 7 x64
I got same when I try to compile my program in...
Hello,I study assembly on High-school and I would like to try to make assembly programs at home.
I downloaded NASM but I don't understand how to run the .s files with it - if you can write a simple way here to run it I'd glad :-)
and in addition I have a question: when I use ADC for exmaple: AL = 01 and BL = 02, and CF = 1, when I make ...