Re: Seg fault with hla 1.99 on Fedora 8 linux



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
;-------------------

.



Relevant Pages

  • Re: Video Mode 13h in windows XP ... impossible?
    ... there is NO problem using mode 13h under XP...if you write a DOS ... terminates so does the "DOS box" and you return to the Windows desktop ... A dedicated assembler (most of which are completely free and available ... NASM, this is _certainty_ that it's okay for you to do so...the people ...
    (alt.lang.asm)
  • Re: Why there are so many assemblers.
    ... But *clearly* the discussion of the creation of NASM predated ... >> reasonable facsimile to the Intel assembler. ... that was in mid-1996), MASM was still a commercial product, TASM was a ... I have a problem with Rene Tournois calling it an "Intel Syntax" ...
    (alt.lang.asm)
  • Re: modify nasm
    ... I'm working in linux and I'd like tomodifyan assembler like nasm (or ... lea r23,5 ... mov r25,r0 ...
    (alt.lang.asm)
  • Re: modify nasm
    ... I'm working in linux and I'd like to modify an assembler like nasm (or ... lea r23,5 ... mov r25,r0 ... It looks like it might be easier to start with some other assembler than Nasm, ...
    (alt.lang.asm)
  • Re: My pick for the 04 election - None of the above
    ... that would be re-usable for each GPL Assembler. ... NASM, and as RosAsm has _years_ of advance on any other ... GPL Asm Encoder for LuxAsm and for RosAsm, ...
    (alt.lang.asm)