예를 들어 00010101과 같은 명령어가 있고 프로그램에 액세스 할 수있는 RAM이 있으면 운영 체제를 사용하지 않고 어셈블리어로 해당 명령어를 excecute 할 수 있습니까? 기능? 나는 인텔을 위해 Fasm을 사용하고있다. 감사.어셈블리 언어로 기계 명령어를 excecute하는 방법 (인텔)
편집 : 나는 이것이 정말로 진절머리 나는 코드라는 것을 안다. 나는 아직 조립하지 않았고, 많은 부분이 잘못되었다는 것을 알고있다.하지만 이것은 학습 목적을위한 것이다. 이것은 바이너리 명령어로 파일을로드하고이를 램에 저장하는 코드의 일부입니다. 다시 한번 나는 이것이 매우 진절머리 나는 것을 안다.
loadkernel:
mov dx, 1F7h
in dx, bl
bt bl, 6 ;this reads the sixth bit of bl and stores it in the carry flag(cf)
cmp cf, 1 ;if bit 6 is one, then the hard drive is signaling that it is ready for the next operation
jz loadkernel
clc ;clear carry flag
beginload:
mov eax, 300h
mov ecx, eax ;copy the starting point of the kernel in memory to ecx
mov ebx, 0 ;clear
mov edx, 0 ;clear
mov bl, 1F4h
out ebx, bl ;give the hard drive the low address of the location of the kernel
mov bl, 1F5h
out 0h, bl ;give the hard drive the high address of the location of the kernel
mov bl, 1F0h
in edx, bl ;read the hard drive
mov [eax], edx ;add kernel data to memory
add eax, 1
inc ebx ;move the hard drive reading head thing forward
mov ip, [eax] ;mov the instruction pointer to memory, so that the computer excecutes the kernel
cmp edx, 0AA55h
jz beginload ;if 0AA55h is not at the end, then read the next data of the kernel.
의 복제본입니다. 매우 도움이됩니다. 이것은 가장 빠른 방법일까요? –
@kjmcgrinder 물론, 모든 코드를 한꺼번에 복사하여 한꺼번에 실행할 수는 있지만 원하는 작업에 따라 다릅니다. 또한 이와 같은 코드를 로딩하면 캐시 등이 무효화되어 성능이 저하되므로 메모리에 코드를 한 번 작성하고 필요하지 않은 경우 다시 쓰지 마십시오 – Earlz