flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Generic Boot and then 2nd file execute with FLOPPY or CD. Goto page Previous 1, 2, 3 |
Author |
|
bitRAKE 06 Oct 2010, 14:42
If there is an error in the code spacing or sector count, then it might always .Exit. Seeing it work on QEMU 1.1 has me doubting there could be such an error. Rather the error is in the BIOS support for loading multiple sectors through INT 13/02. I've seen some BIOS's limited to seven sectors. So, I know this is not a general solution - just an extrapolation of the trick. I've used two emulators and one real machine - only QEMU works - the others fail to load sufficient sectors (resulting in a fall through to .Exit).
If I was in sufficient desire to have the code working I'd remove the spacing and load the code higher -- keeping the size under the seven sector limit I'm currently aware of. No such desire presents itself. |
|||
06 Oct 2010, 14:42 |
|
janequorzar 06 Oct 2010, 16:56
I am starting to think this is a segment alignment issue. I commented out the top line like soo..
Code: org $7C00 - (16*STAGE0.Error..) and I changed it to just plain Code:
org $7C00
and it comes up but with a blank screen with the cursor about a 3rd of the way down. At this point it just hangs the system. Just thought I would share this info. |
|||
06 Oct 2010, 16:56 |
|
bitRAKE 07 Oct 2010, 01:22
Bah, this is getting silly.
The first ORG only effects the .Error message segment:offset. That is why its selection is arbitrary - chosen such that the segment is equal to the string length. Nothing else in the code is changed by the ORG address. How could it possibly work (:in totality) if there were an alignment issue, lol. All I changed was the start address to 0000:7900 and it works everywhere: Code: format binary as "img" ; although beginning at address $7C00 it is not possible to know how every ; BIOS has chosen to segment CS:IP - could be $7C0:0 thru 0:$7C00. org $7C00 - (16*STAGE0.Error..) ; trick to save a byte STAGE0: ; The choice of ES:BX for INT13/02 is important to get STAGE1.Entry aligned ; to STAGE0.Exit -- this is irrespective of memory needed by STAGE1. push STAGE1.SEG mov bx,STAGE1.OFF mov ax,$0200 + STAGE1.SECTORS ; read 130,560 bytes or less mov cx,$0002 ; CHS: 0/0/2 mov dh,ch ; DL from BIOS Boot Specification/BAID pop es int $13 ; Read Disk Sector(s) into Memory .Exit: ; this code only executes when an error occurs cld ; maybe needed? mov si,.Error mov cx,.Error.. mov ds,cx ; trick to save a byte @@: lodsb mov ah,$0E mov bh,$00 int $10 ; Teletype Output loop @B xchg ax,cx int $16 ; Get Keystroke int $19 ; Return to Bootstrap Loader .Error \ ; 0123456789012345678901234567890123456789 db 13,10 db "Rather than silently hide the negative",13,10 db "result which just occured, this message",13,10 db "attempts to amuse the naive and inform",13,10 db "the weary. The plain fact that execution",13,10 db "did not proceed beyond the boot sector",13,10 db "should now be most present in your mind.",13,10 db 13,10 db "---> --> -> > ERROR! < <- <-- <---",13,10 db 13,10 db "Silly. I know.",13,10 db "Some people need an alarmist display.",13,10 .Error.. = $ - .Error db $ and 1 dup 0 ; same as align 2 dw (512-$+$$)/2 dup $AA55 ; pattern fill ;############################################################################### ;############################################################################### org STAGE1.OFF STAGE1: lss sp,[cs:.Entry+1] ; set SS:SP cld push cs push cs pop ds pop es mov ax,$4F00 mov di,.vBuf int $10 ; Detecting VESA cmp ax,$004F jz .VESA.Good mov si,.badVESA call .Print_DS_SI xor si,si @@: mov cx,256/16 call .Print_Dump mov ah,$00 ; Get Keystroke int $16 jmp @B .badVESA db 'VESA: it no workie!',13,10,0 .VESA.Good: mov eax,dword [.vBuf] mov [.A],eax mov ax,[.vBuf.Version] add [.B],ah add [.B+2],al mov si,.dvbeib call .Print_DS_SI lds si,[.vBuf.OEMStringPtr] call .Print_DS_SI push cs pop ds mov si,.crlf call .Print_DS_SI lds si,[.vBuf.OEMVendorName] call .Print_DS_SI push cs pop ds mov si,.crlf call .Print_DS_SI ; decode flags and modes mov ah,$00 ; Get Keystroke int $16 mov ah,$00 ; Get Keystroke int $16 xor si,si jmp @B .dvbeib:db "Dumping VBE InfoBlock",13,10 db "---------------------",13,10 db "Signature: " .A: db "xxxx",13,10 db "Version: " .B: db "0.0" .crlf db 13,10,0 align 16 .vBuf db 'VBE2' ; 'VESA','VBE2' .vBuf.Version dw ? .vBuf.OEMStringPtr dd ? .vBuf.Capabilities dd ? .vBuf.VideoModePtr dd ? ; seg:off .vBuf.TotalMemory dw ? ; 64k blocks ; Added for VBE 2.0 .vBuf.OEMSoftwareRev dw ? .vBuf.OEMVendorName dd ? .vBuf.OEMProductName dd ? .vBuf.OEMProductRevPtr dd ? db 222 dup 0 .vBuf.OEMData db 256 dup 0 ;############################################################################### db $7C00 + (STAGE0.Exit - STAGE0) - $ dup -1 ;############################################################################### ; .LOAD = $7C00 - ($ - $$) + (STAGE0.Exit - STAGE0) ; .LOAD = $1000 .SEG = 0 .OFF = $7900 ;; ONLY CHANGED LINE ;; .Entry: jmp .SEG:.OFF ; set preferred CS:IP ;======================== ; SOME LIBRARY FUNCTIONS: ;------------------------ @@: mov ah,$0E ; mov bh,$00 int $10 ; Teletype Output .Print_DS_SI: lodsb test al,al jnz @B retn .Print_DS.SI: ; Print Segmented Address mov ax,ds call .Print_AX mov ax,$0E00 + ':' ; mov bh,$00 int $10 ; Teletype Output mov ax,si .Print_AX: ; Print Hex Word xchg al,ah ; high byte first call .Print_AL rol ax,4 .Print_AL: ; Print Hex Byte call @F rol ax,4 @@: push ax shr al,4 cmp al,$0A sbb al,$69 das mov ah,$0E ; mov bh,$00 int $10 ; Teletype Output pop ax retn ; ssss:oooo 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 0123456789ABCDEF ; Display CX paragraphs starting at DS:SI .Print_Dump: push cx call .Print_DS.SI mov ax,$0E00 + ' ' int $10 ; Teletype Output mov ax,$0E00 + '|' int $10 ; Teletype Output mov ax,$0E00 + ' ' int $10 ; Teletype Output mov cx,16 @@: lodsb call .Print_AL mov ax,$0E00 + ' ' ; mov bh,$00 int $10 ; Teletype Output loop @B mov ax,$0E00 + '|' int $10 ; Teletype Output mov ax,$0E00 + ' ' int $10 ; Teletype Output push si std lodsb mov cx,16 @@: lodsb ; push cx ; mov cx,1 mov bx,$0004 mov ah,$09 int $10 ; Teletype Output ; pop cx loop @B cld pop si mov ax,$0E00 + 13 int $10 ; Teletype Output mov ax,$0E00 + 10 int $10 ; Teletype Output pop cx loop .Print_Dump retn .SECTORS = ($ - STAGE1 + 511)/512 if .SECTORS > 255 display "ERROR: Second stage is too large!",13,10 end if ; pad to floppy size db 80*2*2*9*512 - ($-$$) - 512 dup (-1) |
|||
07 Oct 2010, 01:22 |
|
janequorzar 07 Oct 2010, 02:50
There you go, an alignment issue.
I knew it had something to do with segment:offset.. but wasn't sure what it was. Thanks for clarifying this unsolved case.. Now I can finally sleep.. I know i'm getting old now.. sheesh... used to eat assembly for breakfast.. now its starting to make me fat.. lol |
|||
07 Oct 2010, 02:50 |
|
bitRAKE 08 Oct 2010, 03:17
Not much of assembly language has changed in 20 years - I'm sure you'll be back to your old self in no time. Might even become lean and mean in the process. Okay, too much optimism.
|
|||
08 Oct 2010, 03:17 |
|
Goto page Previous 1, 2, 3 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.