How can I take mod of a number for instance a%9 in assembly in Motorola M6800.Please tell me which mnemonics should I use.
相关问题
- Null-terminated string, opening file for reading
- What's the difference between 0 and dword 0?
- Translate the following machine language code (0x2
- Where can the code be more efficient for checking
- How can I include a ASM program into my Turbo Basi
相关文章
- How to generate assembly code with gcc that can be
- Select unique/deduplication in SSE/AVX
- Optimising this C (AVR) code
- Why does the latency of the sqrtsd instruction cha
- Difference in ABI between x86_64 Linux functions a
- x86 instruction encoding tables
- Why doesn't there exists a subi opcode for MIP
- Tool to Debug Guest OS in Virtual Box
using easy 68k
At last if memory serves, the 6800 doesn't have a division instruction (IIRC that was added in the 6809), so you'll have to implement division on your own (or, if you don't care about speed, just subtract the divisor repeatedly until the result is less than the divisor, and that's your remainder).
To just figure the remainder (without the division) is actually pretty easy in binary:
For example, let's figure the remainder after dividing 127 by 9. We start by shifting 9 left:
shift left until you get:
Repeatedly shift and subtract:
Since 1 is smaller than 9, we have our remainder: 1. In case you want to check that, 9x14=126.