Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: Frank Kotler <spamtrap@xxxxxxxxxx>
- Date: Fri, 29 Feb 2008 08:52:26 GMT
nbaker2328 wrote:
On Feb 27, 8:08 am, Frank Kotler <spamt...@xxxxxxxxxx> wrote:
Okay, Dave. It appears that HLA does not wear a Red Hat. I am pretty
confident that NASM does, so you might give it a try:
http://nasm.sourceforge.net/
If Nasm had a fan club, I'd be president (maybe "maximum leader", even),
so I won't argue with that suggestion. However... Nasm isn't going to
correspond well with AoA, which is what David would like to do...
Nasm is an assembler isn't it? AoA teaches assembly, right?
Dunno. Nasm is an assembler. Nasm won't assemble what AoA teaches. Conclusion?
It should be possible to convert most of the AoA examples to Nasm
source using the C library for the I/O stuff. Alternatively, one
could convert them directly to C code using inline assembly.
Sure, "echo the answer is 5" is possible, too. Or "just call printf". Or we could use the HLA library (stepping through it, Wolfgang's right - detoured) from Nasm, too, or vid's fasmlib (which, despite the name, is for Nasm too). Maybe David doesn't care too much if it runs on Windows... we could do it with Jeff Owens' lib, or we could do it without no steenking library.
Start with something simple... Linux only. We can add ExitProcess and WriteFile later...
Best,
Frank
; nasm -f elf hwint.asm
; ld -o hwint hwint.o
global _start
section .data
hiya db "Hello, World of (real) Assembly Language!", 10
; "$", in this context, means "here", the current offset
; in the file, so this calculation counts characters.
hiya_len equ $ - hiya
; ans db "InitDemo's value is Segmentation Fault", 10
; naw, that's *too* simple
ans db "InitDemo's value is "
ans_len equ $ - ans
InitDemo dd 5
section .text
_start:
mov ecx, hiya
mov edx, hiya_len
call write_stdout
mov ecx, ans
mov edx, ans_len
call write_stdout
mov eax, [InitDemo]
call showeaxd
call newline
xor eax, eax ; claim "no error".
exit:
mov ebx, eax ; error/return code in ebx (bl, actually)
mov eax, 1 ; __NR_exit
int 80h
;-----------------------
;---------------------------------
showeaxd:
pusha ; save caller's regs
sub esp, 10h ; make buffer on stack
lea ecx, [esp + 10h] ; start at "end" of buffer
mov ebx, 10 ; for decimal, divide by 10
xor esi, esi ; length counter
..top:
dec ecx ; work towards "front" of buffer
xor edx, edx ; "div" works with edx:eax!
div ebx ; quotient in eax, remainder in edx
add dl, '0' ; convert number to ascii char
mov [ecx], dl ; store it
inc esi ; count it
or eax, eax ; quotient zero?
jnz .top ; do more
mov edx, esi ; length in edx
call write_stdout ; print it
add esp, 10h ; free the buffer
popa ; restore caller's regs
ret
;---------------------------------
;-------------------
newline:
pusha
push 10 ; linefeed
mov ecx, esp ; stack is the buffer
mov edx, 1 ; just one
call write_stdout
add esp, 4 ; free buffer
popa
ret
;------------------
;------------------
write_stdout:
mov ebx, 1 ; STDOUT
mov eax, 4 ; __NR_write
int 80h
ret
;-------------------
.
- Follow-Ups:
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: Herbert Kleebauer
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- References:
- Seg fault with hla 1.99 on Fedora 8 linux
- From: DaveR
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: Frank Kotler
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: nbaker2328
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: DaveR
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: nbaker2328
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: Frank Kotler
- Re: Seg fault with hla 1.99 on Fedora 8 linux
- From: nbaker2328
- Seg fault with hla 1.99 on Fedora 8 linux
- Prev by Date: Re: [Clax86list] Seg fault with hla 1.99 on Fedora 8 linux
- Next by Date: referring to segment offsets in read address mode
- Previous by thread: Re: Seg fault with hla 1.99 on Fedora 8 linux
- Next by thread: Re: Seg fault with hla 1.99 on Fedora 8 linux
- Index(es):
Relevant Pages
|