Re: Need tutorials, guides... However...
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Sun, 20 May 2007 19:34:52 GMT
zacariaz@xxxxxxxxx wrote:
You all have really good point.
How odd it may sound, i see no reason to learn assembly, enless i am
gonna use it for special purposes, and the special purposes im
thinking of does do include term like, dos, windows or linux. Like it
or not.
Okay.
The prime example, still being an example, may not be the best
example. Thinking about it i think it is better just to say that i
want to roll my own OS. The reason for this is only that i want to
understand how the computer works. I want to know which binary
sequence adds one number to another, how when where etc.
There is no real reason for all this other than i like to understand
how things works.
Okay.
Anyway, being able to call your self "professional assembly
programmer" is not a bad thing.
Remember the good old days when that and a dime would buy you a cup of coffee? :)
I guess you want to start with a bootsector. Here's one that shows register values. Maybe you can modify it to show what the "add" instruction does... and so on... it would be a *hell* of a lot easier to use dos to learn asm, then use asm to learn to write your bootector, to load your prime-finder or whatever. But if you don't wanna, you don't wanna...
Best,
Frank
;------------------------------------
; shows register values on bootup
;
; nasm -f bin -o bootregs.bin bootregs.asm
;
; dd count=1 if=bootregs.bin of=/dev/fd0
; or
; debug bootregs.bin
; w 100 0 0 1
; q
;-------------------------------------
org 7C00h
section .text
call overdata ; Call? WTF? Don't worry, we pop the
; return address off to get initial IP.
; Note that "call" is longer than
; nop ; "jmp short", so we don't want the nop
db 'MyOS ' ; OEM id - space-padded to 8 bytes
dw 200h ; bytes/sector
db 1 ; sectors per cluster
dw 1 ; sectors before FAT
db 2 ; number of FATs
dw 0E0h ; max rootdir entries
dw 0B40h ; total sectors
db 0Fh ; media descriptor
dw 9 ; sectors per FAT
dw 12h ; sectors per track
dw 2 ; number heads
times 0Ah db 0
db 29h
db 0EFh
db 7
db 10h
db 24h
db 'LINUX BOOT FAT12 ' ; guess where I
; cribbed this from
;----------------------------
overdata:
push sp ; note that we're doing all these
push ss ; pushes to a "wild" stack. Not
push es ; good. (0000:03FA on my system - yipes!)
push ds ; In a real boot-sector, I'd set up a
push cs ; sane stack - very first thing!
push bp
push si
push di
push dx
push cx
push bx
push ax
mov ax, 0B800h ; screen memory - we assume not mono
mov es, ax ; also not good.
xor di, di
mov ds, di
mov cx, 80 * 25 * 2
rep stosb ; clear screen (al is zero from above)
mov di, 80 * 5 * 2
mov cl, 13 ; ch is clear
mov si, regnames
nextreg:
push cx ; save reg-loop counter
mov cx, 5 ; char counter for names
mov ah, 3 ; color
nextchar:
lodsb
stosw
loop nextchar
pop cx ; reg-loop counter
pop dx ; value of reg
mov bx, 4 ; nibble loop counter
nextnibble:
rol dx, 4 ; rotate a nibble into position
mov al, dl ; make a copy to process
and al, 0Fh ; isolate nibble
cmp al, 10 ; short way to convert a nibble
sbb al, 69h ; to hex ascii
das
mov ah, 03h ; color
stosw ; write char and attribute to screen
dec bx ; loop counter for nibbles
jnz nextnibble
add di, 80 * 2 - 18 ; next line
loop nextreg
blackhole:
jmp blackhole
regnames:
db 'ax = '
db 'bx = '
db 'cx = '
db 'dx = '
db 'di = '
db 'si = '
db 'bp = '
db 'cs = '
db 'ds = '
db 'es = '
db 'ss = '
db 'sp = '
db 'ip = '
times 510-($-$$) db 90h ; don't think it matters, but we'll use NOP
db 55h, 0AAh ; boot sector signature
;-------------------------
.
- Follow-Ups:
- Re: Need tutorials, guides... However...
- From: s_dubrovich
- Re: Need tutorials, guides... However...
- References:
- Need tutorials, guides... However...
- From: zacariaz
- Re: Need tutorials, guides... However...
- From: T.M. Sommers
- Re: Need tutorials, guides... However...
- From: zacariaz
- Need tutorials, guides... However...
- Prev by Date: Question for Herbert
- Next by Date: Re: Question for Herbert
- Previous by thread: Re: Need tutorials, guides... However...
- Next by thread: Re: Need tutorials, guides... However...
- Index(es):
Relevant Pages
|