Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

nasm - How to fix float-comma exception

Here we must sum all the elements from diagonal of n x n Matrix = = a_0 + a_n+1 + a_2*(n+1) + a_3(n+1) + ....

User enters all the n x n elements and n (width of matrix) in command line with running of program

section .bss
Trace resb 2 
n resb 1

section .text
 global _start
 _start:

 mov eax, 0
 mov [Trace], eax ;put zero in Trace by eax
 pop ecx          ;wideness of Matrix was on a top of Stack, now its ;in ecx - counter
 dec ecx           
 mov [n], ecx  ;step of summing = n-1
 mov ebx, [n]  ;register ebx will used except n in add, div ...opers
 inc ecx
 mov eax, ecx
 mul ecx      ; n x n = amount of elements in matrix

 pupa:
  pop edx ; taking another element of Matrix
  cmp ecx, 0x00
  je condition ; if zero => a_0 => summ with Trace

  mov eax, ecx
  div ebx         ; eax/n <=> counter / n (with ROUNDING)
  mul ebx         ; eax * n
  cmp eax, ecx; comparing (counter/n * n) and counter, if they`re ;equal => counter mod n = 0 <=> counter = kn, k э N, {0}
  jne pupa ; stop loop if mod n != 0
;-------------------------if counter mod n = 0---------------
  condition: 
   add [Trace], edx  
 
 loop pupa

 mov ax,[Trace];The task was - to produce trace and to move it in ax

; ~return 0
 mov eax, 1
 mov ebx, 0
 int 0x80
question from:https://stackoverflow.com/questions/65909588/how-to-fix-float-comma-exception

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...