0

I'm new to the Assembly programming language. I'm trying to compile a simple booter code in Ubuntu from a book. This code supposes to be a minimal booter to boot an operating system. I'm kind of sure that there is no error in the code because every time I change part of the code the compiler shows some errors.

The code is:

.globl _main,_prints,_NSEC
.globl _getc,_putc,_readfd,_setes,_inces, _error   
BOOTSEG = 0x9800                                   
OSSEG = 0x1000                                     
SSP = 32*1024                                      
BSECTORS = 2                                       

start:
mov ax, BOOTSEG                                    
mov es, ax

xor dx, dx                                         
xor cx, cx                                         
incb cl                                            
xor bx, bx                                         
movb ah, #2                                        
movb al, #BSECTORS
int 0x13

jmpi next, BOOTSEG
next:
mov ax, cs
mov ds, ax
mov ss, ax
mov sp, #SSP
call _main
jmpi 0, OSSEG 

_getc: 
xorb ah, ah
int 0x16
ret
_putc:
push bp
mov bp, sp
movb al, 4[bp]
movb ah, #14
int 0x10
pop bp
ret
_readfd:
push bp
mov bp, sp
movb dl, #0x00
movb dh, 6[bp]
movb cl, 8[bp]
incb cl
movb ch, 4[bp]
xor bx, bx
movb ah, #0x02
movb al, _NSEC
int 0x13
jb _error
pop bp
ret
_setes:
push bp
mov bp, sp
mov ax, 4[bp]
mov es, ax
pop bp
ret
_inces:
mov bx, _NSEC
shl bx, #5
mov ax, es
add ax, bx
mov es, ax
ret
_error:
push #msg
call _prints
int 0x19
msg: .asciz "Error"

, the command is:

sudo as86 ts.s -o ts.o

, and the error is:

as: error reading input

Please help...

  • 1
    I've never used as86 so I don't know if it matters, but the manual seems to suggest that the source file should be placed last on the command line, i.e. `as86 -o ts.o ts.s` – Michael Mar 14 '23 at 11:10
  • 2
    Why do you execute this program with sudo? Do not stick sudo in front of random commands if they don't do what you expect them to do unless you know that they need to be run as the super user. – fuz Mar 14 '23 at 11:56
  • Does `ls -l ts.s` show your file when you run it from the same directory you ran `as86` from? What does `strace -efile as86 -o ts.o ts.s` say? That should show you the filesystem-related system calls `as86` makes, including `open()` where it tries to use the path you supplied. – Peter Cordes Mar 14 '23 at 12:09

0 Answers0