Re: Nasm Error
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Fri, 30 Nov 2007 15:35:27 +0100
Frank Kotler wrote:
...
But I downloaded the C-source and Frank's C-style is somehow goodNot mine. But the folks who coded it are obviously aware of asm, and
readable [ASM-influenced?] for me, so I can see how/why/when NASM
will work.
know what "just call printf" is actually asking to do, so I'd expect a
fairly "sane" coding style. They know better than to "throw library
routines up into the tree until the correct answer falls out".
:) a good one.
So this will help me to figure out how L'unix should be treated ...Most of Nasm is designed to be OS-ignorant. The output "drivers",
outelf32.c and outelf64.c might be some help.
Yeah, that's what I'll study in detail.
Perhaps I once write a C-compiler for KESYS, or just a smart scriptUnless I'm mistaken, the library is a bigger deal than the compiler.
converter. I'd estimate it could produce final files with at least
100:1 source/code-size ratio without loosing execution speed.
Yes, I decided to split the whole story, so have two ways to go.
One is to use my disassembling code-analyser on final executables files
and recreate it just based on functionality,
the other should be able to convert source code into KESYS-script.
Nasm uses only a small subset that cares about OS - open, read, write,
close, malloc, free. If you could arrange these to do "KESYS_open", etc.
you'd be halfway there.
Right, this parts look easy to imply.
Nasm uses libc for strthis and strthat all over the place, of course, but
existing code ought to run on any OS - or it can be implemented in asm.
Here my problem starts, KESYS (as it is now) will never execute foreign
code, because this made its main advantage as a top-secure system.
But why? You seem to be doing okay with the tools you've got. If you
have reason to write/port a C compiler - and the little matter of the
library - then you get Nasm "for free", pretty much. If not, Nasm might
not be the best place to start.
The ideas is to once release a GP-version of KESYS, so I started to collect
information about what it should contain and where it may find its place.
I think it should have:
an assembler/debugger toolbox beside HEXEDIT_64 and KESYS-G-script,
support for x86 16/32/64-bit FASM/NASM/RosASM-syntax,
import/export opportunities for FAT/NT/ext2-formatted drives
and if possible at all a port to and from Linux source? and/or code?.
To get a "L'unix" (the system run by L'unitics) subsystem going, start
simple:
:)
mov eax, 1
int 80h
That ought to return to the KESYS "shell", I suppose - whatever you do.
I'd have to convert it into:
--User level
mov eax, 0
int 7fh
--SYS/Admin-level
call fn_0000
Then:
mov ebx, 42
mov eax, 1
int 80h
I don't know what, if any, attention KESYS pays to "exit codes" or
"errorlevels", but... do what you do.
My returns indicate errors only by flags, NC means No Error, in case
of Carry eax holds an error number, but resulting/valid data else.
Sometimes I just use the return address as error number:
___
....
CMOVC eax,[esp];the return address tells which call failed
JC error ;try to recover or display errmsg
RET
___
C can call it as "exit(42)", and get the same code as the int 80h with
eax=1 executes. eax=2 is "fork"... etc. I suspect there will be a lot of
syscalls that just "don't apply", though.
A quick scan over the Linux syscall list show just a few which may need
additional functions ...
And the C-convention really asks to be interpreted and converted into
meaningful (for KESYS yet) statements.
I suppose you'll want a loader. Maybe you can figure out something by
looking at outelf32.c, but it produces linkable object code. Maybe
looking at programs done "Herbert style" with the elf header laid out
would be simpler. Here's a fairly "minimal" example...
Yes in fact this style gives me a faster insight, ...
Best,
Frank
Thanks Frank and all who wrote "this readable C source" ;)
__
wolfgang
[map all hw.map];===========================================================================
bits 32header -----------------------------------
ORIGIN equ 8048000h
org ORIGIN
section .text
code_offset equ 0
code_addr:
;--------------------------- ELF
dd $464c457f,$00010101,0,0,$00030002,1,main,$34,0,0,$00200034,2,0code ------------------------------------------
dd 1,code_offset,code_addr,code_addr,code_filez,code_memsz,5,4096
dd 1,data_offset,data_addr,data_addr,data_filez,data_memsz,6,4096
;---------------------------
main:data ---------------------------------
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, msg_len
int 80h
mov eax, 1
int 80h
;--------------------------- constant
; (note that we're in .text, not .rdata);---------------------------------------------------------------------------
align 4
; we have none
align 4data ------------------------------
code_memsz equ $ - $$
code_filez equ code_memsz
data_addr equ (ORIGIN+code_memsz+4095)/4096*4096 + (code_filez
% 4096)
data_offset equ code_filez
section .data vstart=data_addr
;--------------------------- initialized
;---------------------------------------------------------------------------
msg db "Hello from Nasm, all by itself!", 10
msg_len equ $ - msg
idat_memsz equ $ - $$data ----------------------------
bss_addr equ data_addr + ($ - $$)
section .bss vstart=bss_addr
;--------------------------- uninitialized
;---------------------------------------------------------------------------
; we have none
udat_memsz equ $ - $$;===========================================================================
data_memsz equ idat_memsz + udat_memsz
data_filez equ idat_memsz
.
- References:
- Nasm Error
- From: fred smith
- Re: Nasm Error
- From: H. Peter Anvin
- Re: Nasm Error
- From: fred smith
- Re: Nasm Error
- From: H. Peter Anvin
- Re: Nasm Error
- From: fred smith
- Re: Nasm Error
- From: Frank Kotler
- Re: Nasm Error
- From: fred smith
- Re: Nasm Error
- From: Frank Kotler
- Re: Nasm Error
- From: Betov
- Re: Nasm Error
- From: Wolfgang Kern
- Re: Nasm Error
- From: Frank Kotler
- Nasm Error
- Prev by Date: Re: Usage of Assembly
- Next by Date: Re: usage of assembly
- Previous by thread: Re: Nasm Error
- Next by thread: Re: Nasm Error
- Index(es):
Relevant Pages
|