Invalid opcodes
Posted: Fri Oct 17, 2008 10:40 am
Hi there,
I will probably sound stupid, but i have been getting invalid opcode exceptions. I'm sure it's due to my dodge jmping, as i am implementing app loading.
GRUB loads it as a module and I jump to it. However, while jmping, my exception prints out an invalid opcode exception error. Please help.
Code:(C calling the asm code)
The prototype for _asm_jmp is:
and the pure asm binary which utilises my kernel's system calls is:
While the lib file is:
If you need any more info just ask. The command for compiling test.asm into test.bin which is loaded by GRUB is:
Thanks in advance,
~souradipm
I will probably sound stupid, but i have been getting invalid opcode exceptions. I'm sure it's due to my dodge jmping, as i am implementing app loading.
GRUB loads it as a module and I jump to it. However, while jmping, my exception prints out an invalid opcode exception error. Please help.
Code:
Code: Select all
if(mb->mods_count>0){
con_print("Jumping to loaded app...");
_asm_jmp(&mb->mods_addr);
con_print("\nThis shouldnt be displayed - _exit system call forwards execution somewhere else");
}
The prototype for _asm_jmp is:
Code: Select all
extern void _asm_jmp(uint32_t*);
Code: Select all
[BITS 32]
%include "../lib/libretasm/lib.asm"
main:
mov ebx, str1
call con_print
call getch
call _exit
cli
hlt
.data
str1 db "Yay! This is from an app loaded by Retix!!!\n\nPress any key to exit."
Code: Select all
; ASM Syscall wrappers
; con_print
; IN : ebx - String to print
; OUT : none
con_print:
mov eax, 0
int 0x80
ret
; getch
; IN : none
; OUT : none
getch:
mov eax, 5
int 0x80
ret
; malloc
; IN : ebx - amount
; OUT : eax - location
malloc:
mov eax, 1
int 0x80
; malloc
; IN : ebx - location
; OUT : none
free:
mov eax, 7
int 0x80
; con_put
; IN : ebx - char
; OUT : none
con_put:
mov eax, 1
int 0x80
; _exit
; IN : none
; OUT : none
_exit:
mov eax, 13
int 0x80
Code: Select all
nasm -fbin -o test.bin test.asm
~souradipm