所以我正在制作一些能够将命令解释为“转到ram location(ex)”的代码。用户键入的命令应该是
JMP 0F01
我已经发现JMP
,它正在解释之后的位置并实际跳转到位置0F01。我在编译时遇到了麻烦,NASM说未指定大小并且我在修复此问题时遇到了很多麻烦。如果其他人发现比这更好的版本,请告诉我。
; --------------------------------------------------------------------------------------------------
; kernel_jump_command -- jump to a location in RAM
; IN/OUT: command
kernel_jump:
mov si, command
mov [.offset], 0x00
inc si
inc si
inc si
; See if we can get anything else than a ' ' or a 0
.a1:
mov [si], al
inc si
cmp al, ' '
je .a1
cmp al, 0x00
je .b1
jmp .c1
.b1:
jmp kernel
.c1:
mov di, .ctable ; Load the table into di
mov cx, 16 ; Loop through all 16 hex
.c2:
mov [di], ah ; Load values
mov [si], al ; Load command letter
inc di
;Check requiorments
cmp al, 0x00 ; If its the end of the string
je .d1 ; Go to execute code
cmp al, ah ; If al and ah match
je .e1 ; Add into the ram loc
loop .c2 ; Loop back
; We have checked through all the letters
.c3:
inc si ; Increase si
sub di, 16 ; Subtract back to begining of char
jmp .c2 ; Loop back to .c2
.d1:
jmp [.ramloc]
.e1:
mov cx, WORD si ; Move the location of si into ecx
add di, 16 ; Add 16 to di so we can get the number
mov si, .ramloc ; Get the location of ramloc
add si, [.offset] ; Add offset to ramloc
inc [.offset] ; Increase offset
;No need to sub16 because its defined in .c3
mov si, WORD cx ; Move back ecx
jmp .c3
.ramloc times 32 db 0
.offset db 0x00
.ctable db '0123456789ABCDEF'
.htable db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15