-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chen Cai
committed
Sep 4, 2018
1 parent
bc1185d
commit d3f197d
Showing
4 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
;;============================================================================= | ||
;; Gauss Calculation | ||
;; 1 + 2 + 3 + ... + 100 = ? | ||
;; We dont use gauss fomula (i.e. paring numbers) | ||
;; Just use computer to calculate the addition which must be faster than Gauss. | ||
;;============================================================================= | ||
|
||
org 7c00h | ||
|
||
%include "inc/io.inc" | ||
|
||
init: | ||
jmp Start | ||
DECLARE_IO_API | ||
|
||
section .text | ||
Start: | ||
cls | ||
mov ax, 1 ;; operand | ||
mov dx, 0 ;; sum | ||
mov cx, 100 | ||
|
||
ADD: | ||
add dx, ax | ||
inc ax | ||
loop ADD | ||
|
||
PrintResult: | ||
mov si, msg | ||
call puts | ||
|
||
mov ax, dx | ||
call Disp2ByteInHex | ||
|
||
End: | ||
jmp $ | ||
;;============================================================================= | ||
|
||
msg db '1+2+3+4+...+100=0x', 0 | ||
;;============================================================================= | ||
|
||
times (512-($-$$) - 2) db 0 | ||
db 0x55, 0xAA ;2 byte boot signature | ||
;;============================================================================= |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.