Wednesday, 15 April 2015

nasm - Explanation of a few lines in Assembly -



nasm - Explanation of a few lines in Assembly -

bits 16 org 0x7c00 start: jmp loader ;******; ; oem parameter block ;********; times 0bh-$+start db 0; line bpbbytespersector: dw 512 bpbsectorspercluster: db 1 bpbreservedsectors: dw 1 bpbnumberoffats: db 2 bpbrootentries: dw 224 bpbtotalsectors: dw 2880 bpbmedia: db 0xf0 bpbsectorsperfat: dw 9 bpbsectorspertrack: dw 18 bpbheadspercylinder: dw 2 bpbhiddensectors: dd 0 bpbtotalsectorsbig: dd 0 bsdrivenumber: db 0 bsunused: db 0 bsextbootsignature: db 0x29 bsserialnumber: dd 0xa0a1a2a3 bsvolumelabel: db "mos floppy " bsfilesystem: db "fat12 " ;******** ; bootloader entry point ;**********; loader: cli hlt times 510 - ($-$$) db 0 dw 0xaa55

now problem don't quite understand times 0bh-$+start evaluates in case. illustration $-$$ = size of program. heĺpful if can explain me lodsb syntax. why there : sign after each of bpb , bs statements? doesn't : sign mean origin of new section, in case of loader section or start section in program. please explain in detail how next evaluates answer.

thanks.

ah! "this line" reserves space "oemname". set name of os there, if - padded 11 bytes. ($$ same "start" - origin of section - 0x7c00 - in case).

not much "syntax" lodsb, it's instruction... http://home.myfairpoint.net/fbkotler/nasmdocc.html#section-a.4.141 (did confuse using "lodbs" illustration of typoed instruction? sorry.)

the ":" absolutely nothing. in case of label lone on line, informs nasm intended label, , isn't typoed instruction. in manual "orphan_label". nasm (optionally - default on) warn if there's no ":", right thing anyway.

you ought have nop after jmp start, since nasm emit "short" jmp (older versions of nasm defaulted near jmp). since entire purpose of "this line" set remaining bpb variables in right place, might it!

assembly nasm bootloader

No comments:

Post a Comment