Covert c program to assembly language program Compiler uses -S option to generate assembly language code for the given c source code. Below is the c source code(program.c). #include <stdio.h> int main() { int a, b, c; a = 20, b = 30; c = a + b; printf("Sum of two numbers is %d\n", c); return 0; } C source code can be converted to assembly code using the following command. jp@jp-VirtualBox:~/$ gcc -S program.c jp@jp-VirtualBox:~/$ ls program.c program.s Below is the assembly code for the above given c source code. .file "program.c" .section .rodata .LC0: ...
Far pointer: Size of the far pointer is 4 bytes and it can point to 1MB of memory. 4 bytes = 32 bits Far pointer has a 16 bit segment address and a 16 bit offset value. Below is the declaration for far pointer char far *ptr; Consider, a 32 bit address is stored in far pointer. char far *ptr = 0x82340005 Here, the 16 bit segment address is 0x8234 and offset value is 0x0005. So, below is the segment offset pair for 0x82340005 segment:offset = 0x8234:0x0005 Let us see how to convert segment offset pair to 20-bit physical address. Left shift the segment address by 4 bit = 0x8234 << 0x4 = 0x82340 Now, add the left shifted segment address and offset value to get 20 bit physical address. 20 bit physical address = (left shifted segment address)0x82340 + (offset)0x0005 ...
Comments
Post a Comment