| 4.3 Introduction to Assembly Programming |
add & sub Read IA-32 Volume 2a [4]
and Read IA-32 Volume 2b [5]
idiv & imul Read IA-32 Volume 2 [4]
Please note the register restrictions.
#include "cdecl.h"
int PRE_CDECL asm_main( void ) POST_CDECL;
int main()
{
int ret_status;
ret_status = asm_main();
return ret_status;
}
curl -o linux-ex.zip http://drpaulcarter.com/pcasm/linux-ex.zip
unzip linux-ex.zip
make (create initial objects and executables)
pico lt1.asm)
nasm -f elf lt1.asm)
gcc -o lt1 driver.o lt1.o asm_io.o)
./lt1)
make)
dump_regs at least once in your program.
|
N | A | B | C | D |
| 0 | 128 | 0x56 | 3 | 27 |
| 1 | 256 | 0x00 | 17 | 31 |
| 2 | 1024 | 0x12 | 23 | 47 |
| 3 | 2048 | 0x34 | 97 | 51 |
| 4 | 4096 | 0x77 | 22 | 71 |
| 5 | 8192 | 0xA7 | 153 | 3 |
| 6 | 64 | 0x80 | 9 | 7 |
| 7 | 32 | 0xB2 | 16 | 171 |
| 8 | 16 | 0x42 | 31 | 72 |
| 9 | 8 | 0x26 | 18 | 147 |
|
N | W | X | Y | Z |
| 0 | A+B | B+C | W/C | W*W |
| 1 | A+C | B+D | X/C | W*X |
| 2 | A+D | B+A | W/C | W*Y |
| 3 | B+C | A-D | X/C | W*W |
| 4 | B+D | C+A | W/C | X*X |
| 5 | C+D | D+A | X/C | X*Y |
| 6 | A+B | B-D | W/C | X*X |
| 7 | A+C | A-C | X/C | X*W |
| 8 | A+C | D-A | X/A | X*Y |
| 9 | A+C | B+D | X/A | X*C |
| 4.3 Introduction to Assembly Programming |