Finally get rid of the old DX:AX for file length 16-bitism
authorH. Peter Anvin <hpa@zytor.com>
Sat, 23 Feb 2008 06:55:06 +0000 (22:55 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 23 Feb 2008 06:55:06 +0000 (22:55 -0800)
Finally scrub the code and get rid of the old uses of DX:AX for file
size (rather than EAX).

bootsect.inc
com32.inc
comboot.inc
extlinux.asm
font.inc
getc.inc
isolinux.asm
ldlinux.asm
pxelinux.asm
runkernel.inc
ui.inc

index 71d595a..7e8f416 100644 (file)
@@ -34,9 +34,6 @@ is_bss_sector:
                mov byte [CopySuper],superblock_len
 %endif
 load_bootsec:
-               xchg dx,ax
-               shl eax,16
-               xchg dx,ax              ; Now EAX = file length
                mov edi, 100000h
                mov [trackbuf+4],edi    ; Copy from this address
                push edi                ; Save load address
index ac51359..9995420 100644 (file)
--- a/com32.inc
+++ b/com32.inc
@@ -43,8 +43,7 @@ com32_rmidt:
                section .text
 is_com32_image:
                push si                 ; Save file handle
-               push dx                 ; File length held in DX:AX
-               push ax
+               push eax                ; Save file length
 
                call make_plain_cmdline
                ; Copy the command line into the low cmdline buffer
index 3a9b433..7c0f40f 100644 (file)
@@ -71,9 +71,7 @@ comboot_too_large:
 ; do, however, allow the execution of INT 20h to return to SYSLINUX.
 ;
 is_comboot_image:
-               and dx,dx
-               jnz comboot_too_large
-               cmp ax,0ff00h           ; Max size in bytes
+               cmp eax,0ff00h          ; Max size in bytes
                jae comboot_too_large
 
                push si                 ; Save file handle
@@ -409,8 +407,7 @@ comapi_open:
                pop ds
                call searchdir
                jz comapi_err
-               mov P_AX,ax
-               mov P_HAX,dx
+               mov P_EAX,eax
                mov P_CX,SECTOR_SIZE
                mov P_SI,si
                clc
@@ -698,8 +695,7 @@ comapi_runkernel:
 
                ; The kernel image was found, so we can load it...
                mov [Kernel_SI],si
-               mov [Kernel_EAX],ax
-               mov [Kernel_EAX+2],dx
+               mov [Kernel_EAX],eax
 
                ; It's not just possible, but quite likely, that ES:BX
                ; points into real_mode_seg, so we need to exercise some
index 8b2eff5..61c83d3 100644 (file)
@@ -914,7 +914,7 @@ allocate_file:
 ;           If successful:
 ;              ZF clear
 ;              SI          = file pointer
-;              DX:AX = EAX = file length in bytes
+;              EAX         = file length in bytes
 ;              ThisInode   = the first 128 bytes of the inode
 ;           If unsuccessful
 ;              ZF set
@@ -993,8 +993,6 @@ open_inode:
                mov [bx+file_left],eax
                pop eax
                mov si,bx
-               mov edx,eax
-               shr edx,16                      ; 16-bitism, sigh
                and eax,eax                     ; ZF clear unless zero-length file
                pop gs
                pop cx
index 8847d15..be9a365 100644 (file)
--- a/font.inc
+++ b/font.inc
 ;
 ; loadfont:    Load a .psf font file and install it onto the VGA console
 ;              (if we're not on a VGA screen then ignore.)  It is called with
-;              SI and DX:AX set by routine searchdir
+;              SI and EAX set by routine searchdir
 ;
 loadfont:
-               mov bx,trackbuf                 ; The trackbuf is >= 16K; the part
-               mov cx,[BufSafe]                ; of a PSF file we care about is no
-               call getfssec                   ; more than 8K+4 bytes
+               ; XXX: This can be 8K+4 bytes and the trackbuf is only
+               ; guaranteed to be 8K in size...
+               mov bx,trackbuf
+               mov cx,[BufSafe]
+               call getfssec
 
                mov ax,[trackbuf]               ; Magic number
                cmp ax,0436h
index 275c0fa..eddba80 100644 (file)
--- a/getc.inc
+++ b/getc.inc
@@ -52,7 +52,7 @@ getc_file_lg2 equ 4                   ; Size of getc_file as a power of 2
 ;              open:   Input:  mangled filename in DS:DI
 ;                      Output: ZF set on file not found or zero length
 ;
-;              openfd: Input:  file handle in SI
+;              openfd: Input:  file handle in SI, file size in EAX
 ;                      Output: ZF set on getc stack overflow
 ;
 ;              getc:   Output: CF set on end of file
@@ -73,8 +73,7 @@ openfd:
                mov [CurrentGetC],bx
 
                mov [bx+gc_file],si     ; File pointer
-               mov [bx+gc_bytes],ax    ; Bytes available
-               mov [bx+gc_bytes+2],dx
+               mov [bx+gc_bytes],eax   ; Bytes available
                xor ax,ax
                mov [bx+gc_bufbytes],ax         ; Buffer empty
                mov [bx+gc_unget_cnt],al        ; ungetc buffer empty
index c245769..bc5eff8 100644 (file)
@@ -961,8 +961,8 @@ load_config:
 %include "ui.inc"
 
 ;
-; Enable disk emulation.  The kind of disk we emulate is dependent on the size of
-; the file: 1200K, 1440K or 2880K floppy, otherwise harddisk.
+; Enable disk emulation.  The kind of disk we emulate is dependent on the
+; size of the file: 1200K, 1440K or 2880K floppy, otherwise harddisk.
 ;
 is_disk_image:
                TRACER CR
@@ -970,8 +970,7 @@ is_disk_image:
                TRACER 'D'
                TRACER ':'
 
-               shl edx,16
-               mov dx,ax                       ; Set EDX <- file size
+               mov edx,eax                     ; File size
                mov di,img_table
                mov cx,img_table_count
                mov eax,[si+file_sector]        ; Starting LBA of file
@@ -1152,7 +1151,7 @@ close_file:
 ;           If successful:
 ;              ZF clear
 ;              SI              = file pointer
-;              DX:AX or EAX    = file length in bytes
+;              EAX             = file length in bytes
 ;           If unsuccessful
 ;              ZF set
 ;
@@ -1269,8 +1268,6 @@ searchdir_iso:
                shr eax,SECTOR_SHIFT
                mov [bx+file_left],eax
                pop eax
-               mov edx,eax
-               shr edx,16
                and bx,bx                       ; ZF = 0
                mov si,bx
                pop es
index 0f06315..c8e4aa8 100644 (file)
@@ -1045,7 +1045,7 @@ close_file:
 ;           If successful:
 ;              ZF clear
 ;              SI              = file pointer
-;              DX:AX or EAX    = file length in bytes
+;              EAX             = file length in bytes
 ;           If unsuccessful
 ;              ZF set
 ;
@@ -1089,8 +1089,6 @@ searchdir:
                jnz .badfile            ; If not a file, it's a bad thing
 
                ; SI and EAX are already set
-               mov edx,eax
-               shr edx,16              ; Old 16-bit remnant...
                and eax,eax             ; EAX != 0
                jz .badfile
                ret                     ; Done!
@@ -1110,7 +1108,6 @@ searchdir:
 
 .notfound:
                xor eax,eax
-               xor dx,dx
                ret
 
                section .bss
index 8bb87c2..2f9a03e 100644 (file)
@@ -1037,7 +1037,7 @@ close_file:
 ;           If successful:
 ;              ZF clear
 ;              SI      = socket pointer
-;              DX:AX   = file length in bytes
+;              EAX     = file length in bytes, or -1 if unknown
 ;           If unsuccessful
 ;              ZF set
 ;
@@ -1258,8 +1258,6 @@ searchdir:
                mov eax,[si+tftp_filesize]
                cmp eax,-1
                jz .no_tsize
-               mov edx,eax
-               shr edx,16              ; DX:AX == EAX
 
                and eax,eax             ; Set ZF depending on file size
                pop bp                  ; Junk
index 98d826f..6ee6e52 100644 (file)
@@ -45,9 +45,7 @@
 ; obsolete.
 ;
 is_linux_kernel:
-               and dx,dx
-               jnz kernel_sane
-               cmp ax,1024                     ; Bootsect + 1 setup sect
+               cmp eax,1024                    ; Bootsect + 1 setup sect
                jb kernel_corrupt
 kernel_sane:   push ax
                push dx
@@ -587,10 +585,7 @@ loadinitrd:
                 mov di,InitRD
                 call searchdir                  ; Look for it in directory
                jz .notthere
-
-               mov cx,dx
-               shl ecx,16
-               mov cx,ax                       ; ECX <- ram disk length
+               mov ecx,eax                     ; ECX <- ram disk length
 
                mov ax,real_mode_seg
                mov es,ax
diff --git a/ui.inc b/ui.inc
index 69ba7dc..7d86f00 100644 (file)
--- a/ui.inc
+++ b/ui.inc
@@ -534,16 +534,15 @@ kernel_good_saved:
                ; COMBOOT function INT 22h, AX=0016h.
                mov si,[Kernel_SI]
                mov eax,[Kernel_EAX]
-               mov dx,[Kernel_EAX+2]
 
 kernel_good:
-               pusha
+               pushad
                mov si,KernelName
                mov di,KernelCName
                call unmangle_name
                sub di,KernelCName
                mov [KernelCNameLen],di
-               popa
+               popad
 
                push di
                push ax
@@ -558,7 +557,7 @@ kernel_good:
                pop di
 
 ;
-; At this point, DX:AX contains the size of the kernel, SI contains
+; At this point, EAX contains the size of the kernel, SI contains
 ; the file handle/cluster pointer, and ECX contains the extension (if any.)
 ;
                movzx di,byte [KernelType]