Permalink
Browse files

Added new structure, formed some macro expressions

  • Loading branch information...
1 parent d98958d commit 80dcd262da18074d1d0f4f54eac065cb79acd8a0 @andre-d committed Apr 7, 2011
Showing with 31 additions and 34 deletions.
  1. +1 −0 build
  2. +24 −0 general.inc
  3. +6 −34 numberascii.asm
View
1 build
@@ -0,0 +1 @@
+../fasm numberascii.asm
View
@@ -0,0 +1,24 @@
+; General config
+ newline equ 0xA
+
+; General functions
+ macro exit n{
+ mov ax,1 ; sys_exit
+ mov bx, n ; Error code
+ int 0x80 ; kick the kernel
+ }
+
+ macro printmsg msg
+ {
+ ; Prints a message
+ if (msg eqtype "")
+ local str
+ str db msg,newline
+ mov cx,str
+ mov dx,$-msg
+ mov ax,4 ; sys_write
+ mov bx,1 ; file descriptor
+ int 0x80 ; kick the kernel
+ end if
+
+ }
View
@@ -1,46 +1,18 @@
-
; Convert a number to a string
+include 'general.inc'
+include 'numberascii.inc'
+
format ELF executable 3
entry start
segment readable executable
- CFG_NUMBER = 103
- CFG_ANOTHER_NUMBER = 18721
-
-exit:
- ; Call to exit the program
- ; ebx: int error_code
- mov eax,1 ; sys_exit
- int 0x80 ; kick the kernel
-
-
-exit_clean:
- xor eax,eax ; Set the error code to 0
- jmp exit
-
-
-printmsg:
- ; Prints a message
- ; ecx: char * buffer
- ; edx: int size
- push eax
- push ebx
- mov eax,4 ; sys_write
- mov ebx,1 ; file descriptor
- int 0x80 ; kick the kernel
- pop ebx
- pop eax
- ret
start:
- mov ecx,msg ; Place our message in ecx
- mov edx,msg_size ; Place the size in edx
- call printmsg ; Print the message
- jmp exit_clean ; Now exit cleanly
+ printmsg(MESSAGE) ; Print the message
+ printmsg("Okay...")
+ exit(0) ; Exit cleanly
segment readable writeable
-msg db 'Simple demo to convert an integer to a string',0xA
-msg_size = $-msg

0 comments on commit 80dcd26

Please sign in to comment.