Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
; Example macro with two parameters
; Implements the write system call
; Use macro to make printing to screen more efficient
;We use times to print 20 dots under the messages
%macro write_string 2 ; start micro users two parameter message and message length
mov eax, 4 ; system call write to screen
mov ebx, 1 ; standard out
mov ecx, %1 ; first macro parameter message
mov edx, %2 ; second macro parameter message size
int 80h ; interrupt
%endmacro ; Macro end
section .data ; data section
welcomeMsg db 'Hello, Welcome to this Simple Game',10 ; message of welcome. Note 10 is same as endl in C++
welcomeMsgLen equ $ -welcomeMsg; welcome message length
questionMsg db 'What Letter am I thinking of: ', 10 ; Question message
questionMsgLen equ $ -questionMsg ; Length of question message
sameMsg db 'Well Done You Guessed the Letter Correctly ',10 ; Correct answer message
sameMsgLen equ $-sameMsg ; Correct Message Length
lineDot times 20 db '.' ; print one dot 20 times
cr db 10 ; newline line endl in C++
section .text ;text section where main assembly code is found
global _start ;must be declared for using gcc
_start: ;tell linker entry point
write_string welcomeMsg, welcomeMsgLen ; call macro to print welcome message
write_string questionMsg, questionMsgLen ; call macro to print question
write_string sameMsg, sameMsgLen ; call macro to print correct message
write_string lineDot, 20 ; call macro to print line of Dots
write_string cr, 1 ; call macro to print new line like endl in C++
call done ; call done function
; done function ends the program running
done:
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel