So, my first day of the Assembly lesson, and what do you know? My teacher teaches everything on his Windows box using Windows API calls, etc. Which is great, except that I run Ubuntu on my box.
Basically, I hope that I can find either a workaround or some form of common ground so that I can complete my tasks.
Today our first programming task was to enter two integers and print the sum. I followed my professor's code as follows:
.386
.model flat
ExitProcess PROTO NEAR32 stdcall, dwExiteCode:DWORD
include io.h
cr EQU 0dh
lf EQU 0ah
.stack 4096
.data
szPrompt1 BYTE "Enter first number: ", 0
szPrompt2 BYTE "Enter second number: ", 0
zLabel1 BYTE cr, lf, "The sum is "
dwNumber1 DWORD ? ; numbers to be added
dwNumber2 DWORD ?
szString BYTE 40 DUP (?) ; input string for numbers
szSum BYTE 12 DUP (0) ; sum in string form
szNewline BYTE cr,lf,0
.code ; start of main program code
_start:
output szPrompt1 ; prompt for ?rst number
input szString,40 ; read ASCII characters
atod szString ; convert to integer
mov dwNumber1,eax ; store in memory
output szPrompt2 ; repeat for second number
input szString,40
atod szString
mov dwNumber2,eax
mov eax,dwNumber1 ; first number to EAX
add eax,dwNumber2 ; add second number
dtoa szSum,eax ; convert to ASCII characters
output szLabel1 ; output label and results
output szSum
output szNewline
INVOKE ExitProcess,0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code
Simple and straightforward, huh? So I turned it today, everything is connected to a crappy school computer. And I completely understand all the concepts associated with this, however, I see here 2 main questions if I really want to collect it in my box:
1)
.model flat
2)ExitProcess PROTO NEAR32 stdcall, dwExiteCode:DWORD
And also Both of which I heard are very specific to Windows. So my question is, how can I mutate this code to be able to build on Linux?Sorry if I am missing any details, but I will let you know if you need.
Thank!