duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit af1a0fb2efb6c243235162b9b442487838152d78
parent aa6031fab22b775bab05537f9126292c4260ab84
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed,  1 Jun 2022 13:51:40 -0400

Add emit

This is getting exciting!

Diffstat:
MMakefile | 7+++----
Mdusk.asm | 3+++
Mword_macros.asm | 10++++++++++
Mwords/boot.asm | 14+++-----------
Awords/emit.asm | 8++++++++
5 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,15 +1,14 @@ TARGETS = dusk +WORDOBJS = $(addsuffix .o,$(addprefix words/,bye emit boot)) all: $(TARGETS) %.o: %.asm nasm -f elf32 -p word_macros.asm $< -o $@ -words/boot.o: words/boot.asm -words/bye.o: words/bye.asm -dusk: dusk.asm words/boot.o words/bye.o +dusk: dusk.asm $(WORDOBJS) nasm -f elf32 dusk.asm -o dusk.o - ld -m elf_i386 dusk.o words/*.o -o $@ + ld -m elf_i386 dusk.o $(WORDOBJS) -o $@ .PHONY: clean clean: diff --git a/dusk.asm b/dusk.asm @@ -1,3 +1,4 @@ +; PSP=ebp RSP=esp BITS 32 %define PS_SZ 4096 %define RS_SZ 4096 @@ -13,5 +14,7 @@ SECTION .text _start: cld + mov esp, rs_top + mov ebp, ps_top call word_boot call word_bye diff --git a/word_macros.asm b/word_macros.asm @@ -1,3 +1,13 @@ +%macro pspush 1 ; src + sub ebp, 4 + mov dword [ebp], %1 +%endmacro + +%macro pspop 1 ; dst + mov %1, dword [ebp] + add ebp, 4 +%endmacro + %macro _word 4 ; name namelen lbl prevlbl GLOBAL %3 db %1 diff --git a/words/boot.asm b/words/boot.asm @@ -1,12 +1,4 @@ -SECTION .data -hello: db 'Hello world!',10 -len: equ $-hello - -SECTION .text -defword 'boot', 4, word_boot, word_bye - mov eax,4 ; 'write' syscall - mov ebx,1 ; stdout - mov ecx,hello - mov edx,len - int 80h +defword 'boot', 4, word_boot, word_emit + pspush 0x66 ; 'f' + call word_emit ret diff --git a/words/emit.asm b/words/emit.asm @@ -0,0 +1,8 @@ +defword 'emit', 4, word_emit, word_bye + mov eax,4 ; 'write' syscall + mov ebx,1 ; stdout + mov ecx,ebp ; top of PS, little endian + mov edx,1 + int 80h + pspop eax + ret