Skip to content

Commit

Permalink
tic tac toe complete
Browse files Browse the repository at this point in the history
  • Loading branch information
JudgeGroovyman committed Oct 7, 2019
1 parent 09140d1 commit 9d40d59
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 1 deletion.
4 changes: 3 additions & 1 deletion asm/DosBox/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ DosBox.exe
SDL.dll
SDL_Net.dll
asciitable.gif
DOSBox 0.74-3 Options.bat
DOSBox 0.74-3 Options.bat
stderr.txt
stdout.txt
62 changes: 62 additions & 0 deletions asm/DosBox/library2.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

;org 0x0100
;mov ax,0x0100
;call display_number
;int 0x20
; --------------
int 0x20
; Display letter contained in AL (ASCII)
display_letter:
push ax
push bx
push cx
push dx
push si
push di
mov ah,0x0e ; Load AH with code for terminal output
mov bx,0x000f ; Load BH page zero adn BL color (graphic mode)
int 0x10 ; Call the BIOS for displaying one letter
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret ; Returns to caller
; Read keyboard into AL (ASCII)
read_keyboard:
push bx
push cx
push dx
push si
push di
mov ah,0x00 ; Load AH with code for keyboard read
int 0x16 ; Call the BIOS for reading keyboard
pop di
pop si
pop dx
pop cx
pop bx
ret ; Returns to caller

;
; Display the value of AX as a decimal number
;
display_number:
mov dx,0
mov cx,10
div cx ; AX = DX: AX / CX
push dx
cmp ax,0 ; if ax is zero
je display_number_1 ; jump
call display_number ; else calls itself again
display_number_1:
pop ax
add al,'0' ; convert remainder to ascii digit
call display_letter ; display on the screen
ret
Binary file added asm/DosBox/library2.com
Binary file not shown.
105 changes: 105 additions & 0 deletions asm/DosBox/sieve.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

;
; Sieve of Eratosthenes
;
org 0x0100
table: equ 0x8000
table_size: equ 1000

start:
mov bx,table
mov cx,table_size
mov al,0
p1:
mov [bx],al ; Write AL into the address pointed by BX
inc bx ; increase bx
loop p1 ; Decrease CX, jump if non zero
mov ax,2 ; start at number 2
p2: mov bx,table; BX = table address
add bx,ax ; BX=BX+AX
cmp byte [bx],0 ; is it prime?
jne p3
push ax
call display_number
mov al,0x2c ; Comma
call display_letter
pop ax
mov bx,table
add bx,ax
p4: add bx,ax
cmp bx,table+table_size
jnc p3
mov byte [bx],1
jmp p4
p3: inc ax
cmp ax,table_size
jne p2
; --------------
int 0x20
; Display letter contained in AL (ASCII)
display_letter:
push ax
push bx
push cx
push dx
push si
push di
mov ah,0x0e ; Load AH with code for terminal output
mov bx,0x000f ; Load BH page zero adn BL color (graphic mode)
int 0x10 ; Call the BIOS for displaying one letter
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret ; Returns to caller
; Read keyboard into AL (ASCII)
read_keyboard:
push bx
push cx
push dx
push si
push di
mov ah,0x00 ; Load AH with code for keyboard read
int 0x16 ; Call the BIOS for reading keyboard
pop di
pop si
pop dx
pop cx
pop bx
ret ; Returns to caller


;
; Display the value of AX as a decimal number
;
display_number:
mov dx,0
mov cx,10
div cx ; AX = DX: AX / CX
push dx
cmp ax,0 ; if ax is zero
je display_number_1 ; jump
call display_number ; else calls itself again
display_number_1:
pop ax
add al,'0' ; convert remainder to ascii digit
call display_letter ; display on the screen
ret
Binary file added asm/DosBox/sieve.com
Binary file not shown.
107 changes: 107 additions & 0 deletions asm/DosBox/sieve2.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

;
; Sieve of Eratosthenes
;
org 0x0100
table: equ 0x8000
table_size: equ 1000

start:
mov bx,table
mov cx,table_size
mov al,0
p1:
mov [bx],al ; Write AL into the address pointed by BX
inc bx ; increase bx
loop p1 ; Decrease CX, jump if non zero
mov ax,2 ; start at number 2
p2: mov bx,table; BX = table address
add bx,ax ; BX=BX+AX
cmp byte [bx],0 ; is it prime?
jne p3
push ax
call display_number
mov al,0x0d ; Comma
call display_letter
mov al,0x0a ; Comma
call display_letter
pop ax
mov bx,table
add bx,ax
p4: add bx,ax
cmp bx,table+table_size
jnc p3
mov byte [bx],1
jmp p4
p3: inc ax
cmp ax,table_size
jne p2
; --------------
int 0x20
; Display letter contained in AL (ASCII)
display_letter:
push ax
push bx
push cx
push dx
push si
push di
mov ah,0x0e ; Load AH with code for terminal output
mov bx,0x000f ; Load BH page zero adn BL color (graphic mode)
int 0x10 ; Call the BIOS for displaying one letter
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret ; Returns to caller
; Read keyboard into AL (ASCII)
read_keyboard:
push bx
push cx
push dx
push si
push di
mov ah,0x00 ; Load AH with code for keyboard read
int 0x16 ; Call the BIOS for reading keyboard
pop di
pop si
pop dx
pop cx
pop bx
ret ; Returns to caller


;
; Display the value of AX as a decimal number
;
display_number:
mov dx,0
mov cx,10
div cx ; AX = DX: AX / CX
push dx
cmp ax,0 ; if ax is zero
je display_number_1 ; jump
call display_number ; else calls itself again
display_number_1:
pop ax
add al,'0' ; convert remainder to ascii digit
call display_letter ; display on the screen
ret
Binary file added asm/DosBox/sieve2.com
Binary file not shown.
Empty file removed asm/DosBox/stderr.txt
Empty file.
Empty file removed asm/DosBox/stdout.txt
Empty file.
Loading

0 comments on commit 9d40d59

Please sign in to comment.