Re: Question about jumps
- From: "Evenbit" <nbaker2328@xxxxxxxxxxx>
- Date: 29 Aug 2006 18:24:43 -0700
...and you just keep adding to it...
; nasm -f elf -l stk2.lst -Xvc -O8 -o stk2.o stk2.asm
; ld -s -o stk2 stk2.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
%macro nl 0
mov ecx, lf
mov edx, 1
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
%endmacro
%macro writebuff 2
mov edx, %2
mov ecx, buff
mov ebx, %1
mov eax, _sys_write
int 0x80
%endmacro
global _start
section .data
hw db 'Hello, World!', 10
hwlen equ $-hw
lf db 10
section .bss
buff: times 64 resb 0
section .text
_start:
mov edx, hwlen
mov ecx, hw
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
mov al, '3'
mov [buff], al
mov edx, 1
lea ecx, [buff]
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
nl
mov al, '4'
mov [buff+1], al
writebuff _sys_stdout, 2
nl
writestr _sys_stdout, 'Goodbye, World!', 10
sys_exit 0
....and then you add some more until you run into code that doesn't
work...
; nasm -f elf -l stk3.lst -Xvc -O8 -o stk3.o stk3.asm
; ld -s -o stk3 stk3.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
%macro nl 0
mov ecx, lf
mov edx, 1
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
%endmacro
%macro writebuff 2
mov edx, %2
mov ecx, buff
mov ebx, %1
mov eax, _sys_write
int 0x80
%endmacro
global _start
section .data
hw db 'Hello, World!', 10
hwlen equ $-hw
lf db 10
section .bss
buff: times 64 resb 0
section .text
_start:
mov edx, hwlen
mov ecx, hw
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
mov al, '3'
mov [buff], al
mov edx, 1
lea ecx, [buff]
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
nl
mov al, '4'
mov [buff+1], al
writebuff _sys_stdout, 2
nl
mov dl, 42
call write_hex
nl
writestr _sys_stdout, 'Goodbye, World!', 10
sys_exit 0
write_hex:
push cx
push dx
mov dh, dl
mov cx, 4
shr dl, cl
call write_hex_digit
mov dl, dh
and dl, 0fh
call write_hex_digit
pop dx
pop cx
ret
write_hex_digit:
push dx
cmp dl, 10
jae .hex_letter
add dl, 48
jmp .write_digit
..hex_letter:
add dl, 55
..write_digit:
call write_char
pop dx
ret
write_char:
push eax
push ecx
push edx
push ebx
mov [buff], dl
mov edx, 1
mov ecx, [buff]
mov ebx, _sys_stdout
mov eax, _sys_write
int 0x80
pop ebx
pop edx
pop ecx
pop eax
ret
....then you scratch your nawgin ;)
Nathan.
.
- Follow-Ups:
- Re: Question about jumps
- From: Herbert Kleebauer
- Re: Question about jumps
- From: Frank Kotler
- Re: Question about jumps
- References:
- Question about jumps
- From: Markus Pitha
- Re: Question about jumps
- From: Evenbit
- Question about jumps
- Prev by Date: Re: Question about jumps
- Next by Date: Re: Question about jumps
- Previous by thread: Re: Question about jumps
- Next by thread: Re: Question about jumps
- Index(es):
Relevant Pages
|