Problem 1: write a little C program named "bct" which does the
following:
[NQH]:~/BO$ cat hw.asm
USE32 ; tell nasm we're using 32-bit system
jmp short string
code:
pop ecx ; write(1, "Hello, World!", 13);
mov ebx, 1 ; output file descriptor for write
mov edx, 14 ; length of output string
mov eax, 4 ; 4 is the system call number of write
int 0x80 ; finally, invoke the system call
mov ebx, 0 ;
mov eax, 1
int 0x80
string:
call code
db 'Hello, World!', 0x0a
[NQH]:~/BO$ nasm hw.asm
[NQH]:~/BO$ bct hw
----------------------
Calling your code ...
----------------------
Hello, World!
[NQH]:~/BO$ bct -p hw
----------------------
Printing your code ...
----------------------
char bytecode[] =
"\xeb\x1e\x59\xbb\x01\x00\x00\x00\xba\x0e\x00\x00\x00\xb8\x04\x00"
"\x00\x00\xcd\x80\xbb\x00\x00\x00\x00\xb8\x01\x00\x00\x00\xcd\x80"
"\xe8\xdd\xff\xff\xff\x48\x65\x6c\x6c\x6f\x2c\x20\x57\x6f\x72\x6c"
"\x64\x21\x0a"