Re: Question about jumps



I think a person learns best by playing with existing programs. Here
is a little 'template' or 'starter kit' that you can build on. Just
keep adding macros and subroutines to extend the functionality.

; nasm -f elf -l stk.lst -Xvc -O8 -o stk.o stk.asm
; ld -s -o stk stk.o

; define some system constants

_sys_exit equ 1
_sys_write equ 4
_sys_stdout equ 2

; define some system macros

%macro sys_exit 1
mov eax, _sys_exit
mov ebx, %1
int 0x80
%endmacro

%macro writestr 2+

[section .data]

%%str: db %2
%%endstr:

__SECT__

mov ecx, %%str
mov edx, %%endstr-%%str
mov ebx, %1
mov eax, _sys_write
int 0x80

%endmacro

global _start

section .data

hw db 'Hello, World!', 10
hwlen equ $-hw

section .text

_start:
mov edx, hwlen
mov ecx, hw
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80

writestr _sys_stdout, 'Goodbye, World!', 10

sys_exit 0


Nathan.

.



Relevant Pages

  • Re: The Advantage of Macros
    ... macros (I couldn't figure out how to use his macro library - Nathan ... mov eax, ... locals counter, name ...
    (alt.lang.asm)
  • Re: NASM macros
    ... > mov ebx, %1 ... > sys_write 1, ecx, edx ... I want to wrap the Linux syscalls in macros so as to permit a ...
    (alt.lang.asm)
  • Re: Question about jumps
    ... I think some assemblers dump the symbol table with the listing file, which Nasm doesn't do... ... scale it down a good bit to make a "Linux NASM Beginner Kit" package. ... If "nasm64" ever appears, we'll want macros so ... mov rax, 1; maybe just eax? ...
    (alt.lang.asm)
  • Re: GoAsm And EasyCode
    ... The bottom screenshot at ... perhaps that's the macros you're refering to... ... Mov Eax, ... Mov Ecx, SizeOf MESSAGES / 8 ...
    (alt.lang.asm)
  • Re: Question about jumps
    ... mov eax, _sys_exit ... mov ebx, %1 ... int 0x80 ... mov eax, _sys_write ...
    (alt.lang.asm)