Recent Posts

Pages: [1] 2 3 ... 10
1
Example Code / Re: A little program to seek and write primes, with hardcoded maximum
« Last post by andyz74 on February 02, 2026, 10:31:52 AM »
Also for this topic, there's one variant to seek primes by the "Sieve of Eratosthenes".
Seems to be faster as the other ones, but here, we have huge max-values until 2.100.000.000 hardcoded. You may make this smaller for testing.


Code: [Select]
; 64-bit  ... gibt Primzahlen aus, Sieb des Eratosthenes
; by myself
; nasm -f elf64 primzahlen_sieve_buf_opt.asm
; ld -s -o primzahlen_sieve_buf_opt primzahlen_sieve_buf_opt.o
; time :    sec


[bits 64]

; here just variables ---------------------------------------

SECTION .data


ziffer db 0
zahl db  '0000000000'
crlf db 13,10
msg1 db 'Bitte Geduld! Suche Primzahlen zwischen '
msgl1 db 40
msg2 db 'und '
msgl2 db 4
max dq 2100000000     ; 2,1 Milliarden (Max-Value, we seek primes to)
wmin dq 2099990000 ; This is, where we start to print primes)
;  printing all primes will take long time, therefor the above


section .bss
   
 p_array  :  resb 5400000000 ; 5,4 Milliarden
 
global _start ; global entry point export for ld

SECTION .text

_start:
jmp start2


all_be_primes:
xor r8, r8
weiter:
mov byte [p_array+r8], 1    ; wenn 1, dann prim
inc r8
cmp r8, [max]
jne weiter
ret



make_sieve: ; reminder r8 bis r15 als Register
mov r8, 1    ; das zum durchmultiplizieren.
weiter3:
inc r8
cmp byte [p_array+r8], 1 ; nur Primzahlen weiter multiplizieren! Opt!
jne weiter3
mov r9, r8
weiter2:
add r9, r8
mov byte [p_array+r9], 0        ; wenn 0, dann NICHT prim
cmp r9, [max]
jb weiter2 ; unsigned <
inc r8
cmp r8, [max]
jb weiter3 ; unsigned <
ret



print_dez: ; zahl muss in rax sein.
push rax
push rbx
push rcx
push rdx

xor rcx,rcx
mov rbx,10

schl1:
xor rdx,rdx
div rbx
push rdx
inc rcx
cmp rax,0

jnz schl1

xor r8,r8
schl2:
pop rdx
add dl,30h
mov [zahl+r8],dl
inc r8
loop schl2

mov rax, 1 ; Funktionsnummer : schreiben
mov rdi, 1 ; auf STDOUT
mov rsi, zahl ; was schreiben wir
mov rdx, r8 ; wieviel Zeichen
syscall

mov rax, 1 ; Funktionsnummer : schreiben
mov rdi, 1 ; auf STDOUT
mov rsi, crlf ; was schreiben wir
mov rdx, 2 ; wieviele Zeichen
syscall

pop rdx
pop rcx
pop rbx
pop rax
ret


print_info:
mov rax, 1 ; sys_write
mov rdi, 1 ; stdout
mov rsi, msg1 ; message address
mov rdx, 40 ; msgl1 ; message string length
syscall
mov rax, 1 ; Funktionsnummer : schreiben
mov rdi, 1 ; auf STDOUT
mov rsi, crlf ; was schreiben wir
mov rdx, 2 ; wieviele Zeichen
syscall

mov rax, [wmin]
call print_dez

mov rax, 1 ; sys_write
mov rdi, 1 ; stdout
mov rsi, msg2 ; message address
mov rdx, 4  ;msgl2 ; message string length
syscall
mov rax, 1 ; Funktionsnummer : schreiben
mov rdi, 1 ; auf STDOUT
mov rsi, crlf ; was schreiben wir
mov rdx, 2 ; wieviele Zeichen
syscall

mov rax, [max]
call print_dez

ret




start2:   ; here starts the proggi

call print_info

call all_be_primes

call make_sieve

;  mov byte [p_array+27], 1    ; nur zum testen

mov rax, 0
weiter4:
inc rax
cmp rax, [wmin]
jb weiter4
cmp rax, [max]
ja weiter5
cmp byte [p_array+rax], 1
jne weiter4
call print_dez
cmp rax, [max]
jb weiter4 ; unsigned <
weiter5:



mov rax,60
syscall

2
Example Code / Re: Snake game for MS-DOS (16-bit real mode)
« Last post by Tobiasz Stamborski on June 16, 2025, 02:23:07 PM »
Ok, i don't take offence at all if that's the case. :)
3
Example Code / Re: Snake game for MS-DOS (16-bit real mode)
« Last post by debs3759 on June 15, 2025, 01:00:05 PM »
I didn't mean to offend you. It's a subdomain on a website I don't know, and I had visited a website on my phone the day before which infected my phone, and resetting it then having to set everything up again with some apps wanting to contact my existing app on my "old" phone took half a day, so I was feeling more judgemental than usual. Sorry that I reacted how I did and took it out on you.
4
Example Code / Re: Snake game for MS-DOS (16-bit real mode)
« Last post by Tobiasz Stamborski on May 27, 2025, 12:04:06 PM »
Yeah, I'll go to some random website and load up a program written in assembly in my browser.

I don't understand why exactly you are so malicious. If you are suggesting that i sell malware then simply no. The game is all running inside emulator (js-dos) inside web browser - i don't know how it even could do anything harmful to your computer. afaik it can only save few kB of data inside a cookie.

i don't feel itch.io is a random site. it's well known site for indie games and corelated stuff. i don't want to argue - if you are a moderator and you think my post is inappropriate here then you can delete it.
5
Example Code / Re: Snake game for MS-DOS (16-bit real mode)
« Last post by debs3759 on May 26, 2025, 10:24:16 PM »
Yeah, I'll go to some random website and load up a program written in assembly in my browser.
6
Example Code / Snake game for MS-DOS (16-bit real mode)
« Last post by Tobiasz Stamborski on May 21, 2025, 02:15:47 PM »
Hello,

I want to share with code of my snake game implementation. I know it's rather a full program than an example code.
But i think maybe someone will use it as an example of simple random number generation, playing simple music on the
pc speaker, or anything else. Sorry if i shouldn't post it here.

If you want to see the game, here is a page on itch.io where you can play it in the web browser:
https://tstamborski.itch.io/wild-snake-boa-ii
However HTML5 player there works a bit slow and jaggy. (idk exactly why, in DOSBox it runs fine)

The full source code can be found here:
https://github.com/tstamborski/wild-snake-boa-ii
snakeboa.asm is the main file where program starts.

Sorry for my stupid ideas like making a wallpaper. (if somebody downloaded SNAKEBOA.zip and noticed)

I have created the game for game jam - just to try your hand. It's all running in text mode and just default BIOS
font is replaced by my custom 8x8 font. It's maybe nothing interesting but i thought why not to show it here. ???
7
Hi, I am Lukas,
and I am writing my operating system but I have problem with switching video modes ( switching to VESA modes too ) because I don't know how to do it and I don't found any tutorial on it so I need help. I know that in real mode it can by done by using ah = 0x00 and with interruption 0x10, but I am in protected mode so I don't know how to do it. Can someone help me please?

It don't know does it helpful for you, because it's just about regular VGA modes but:
1. In protected mode you haven't access to BIOS interrupts as you already know. You must to deal directly with VGA i/o registers by self.
2. Here you have the short instruction about VGA registers (how to use them):
https://wiki.osdev.org/VGA_Hardware#VGA_Registers
3. Here you have a proper register settings for few VGA modes (and how you should safely set them up):
https://wiki.osdev.org/VGA_Hardware#Sample_Register_Settings

Generally it's a lot of work before you, so don't expect a simple answer. I think links above are good place to start. BTW: Not so long ago I was trying to write my own simple OS too. I know your pain. :)
8
Website and Forum / Re: Why did the site go down just a few days ago?
« Last post by debs3759 on May 01, 2025, 03:54:09 AM »
That's just speculation, most of us have no idea whether it was a network issue or a software issue. Or something else. No point pointing fingers until someone in the know responds.
9
Website and Forum / Re: Why did the site go down just a few days ago?
« Last post by ben321 on May 01, 2025, 02:57:17 AM »
Assuming the server admin is paying their ISP for a static IP address then you shouldn't have this kind of issue. This kind of issue happens issue when the IP address associated with the domain name becomes obsolete due to the IP address being dynamic (ISP periodically changes your IP address).
10
Website and Forum / Re: Why did the site go down just a few days ago?
« Last post by debs3759 on April 30, 2025, 06:11:50 AM »
I think it was down for over a week. That's not unusual, as the server isn't regularly monitored, amd the site admin isn't around much. It is run by volunteers after all (even if the site admin works (or worked) for Intel :)
Pages: [1] 2 3 ... 10