我試圖進入實數爲2個不同的陣列NASM進入兩個實數爲2個不同的陣列
目前我有這樣的代碼,但它賽格故障我做進入最後的浮點值到右後數組2,
什麼想法?
segment .bss
;
segment .data
prompt1 db "Do you have data to enter? (-1 = yes,0 = no)?: ", 0
prompt2 db "Enter your Float Value: ", 0
prompt3 db "Almost done ",0
segment .text
extern readdouble,print_string, read_int
global readarray
readarray:
pusha
mov ebx, [esp+36] ;move starting position into ebx
mov esi, [esp+40] ;move max values into edx
mov edi, 0 ;initialize counter to zero
read_loop:
mov eax, prompt1
call print_string
call read_int ;read in decision for prompt
inc edi; increment counter
cmp eax, 0
jz Done_reading_array1
jmp continue_loop
continue_loop:
mov eax, prompt2
call print_string
call readdouble
mov [ebx], ecx ;move value into memory slot ebx
mov [ebx+4], edx
add ebx, 8 ;move to next location for db word
jmp read_loop
Done_reading_array1:
sub edi, 1
mov [esp+40], edi ;moves counter back to stack
jmp read_array2
read_array2:
mov ebx, [esp+68] ;move starting location of array1 into ebx
;mov esi,[esp+80] ;move number of items into esi
mov ebp, 0
continue_readarray2:
mov eax, prompt2
call print_string
call readdouble
mov [ebx], ecx ;move value into memory slot ebx
mov [ebx+4], edx
inc ebp
add ebx, 8 ;move to next location for db word
cmp ebp, edi
jz done_reading_array2
jmp continue_readarray2
done_reading_array2:
;mov [esp+72],edi
mov eax, prompt3
call print_string
popa
ret
究竟爲什麼你用匯編語言寫這個? – zwol 2011-04-08 03:51:16