Skip to content

Commit

Permalink
update gauss calculation example
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Cai committed Sep 4, 2018
1 parent bc1185d commit d3f197d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
45 changes: 45 additions & 0 deletions mbr/gauss_calculation.asm
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
;;=============================================================================
41 changes: 0 additions & 41 deletions mbr/gos.asm

This file was deleted.

6 changes: 3 additions & 3 deletions mbr/nmake.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ if not exist bin (
mkdir bin
)

:: Build
nasm -f bin -o bin\%1.bin -l bin\%1.lst %1.asm

if not exist bin\bochsrc.bxrc (
xcopy /Y ..\template\bochsrc.bxrc bin\
xcopy /E /Y ..\template\bxshare bin\bxshare\
Expand All @@ -20,9 +23,6 @@ if not exist system.img (
:: Remove temp files which may prevent starting a new bochs instance
del /s /q system.img.lock

:: Build
nasm -f bin -o %1.bin -l %1.lst ..\%1.asm

dd if=%1.bin of=system.img bs=512 count=1

:: Run
Expand Down
Binary file added screenshots/gauss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d3f197d

Please sign in to comment.