Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .MODEL FLAT
- ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
- Include io.h
- cr equ 0DH
- Lf equ 0AH
- .STACK 4096
- .DATA
- number dword ?
- string byte 40 dup(?)
- rejected byte ", Rejected",cr,0
- positiveNumber byte ", Positive",cr,0
- negativeNumber byte ", Negative",cr,0
- numberOfPos byte "Positive Numbers: ",0
- numberOfNeg byte "Negative Numbers: ",0
- runningSum byte "Running Sum of Positive numbers: ",0
- newline byte cr,Lf,0
- numaschar byte 11 dup(?),0
- numPosaschar byte 11 dup(?),0
- numNegaschar byte 11 dup(?),0
- sumasChar byte 11 dup(?),0
- .code
- _start:
- sub ebx,ebx ; numberOfPos = 0
- sub ecx,ecx ; numberOfNeg = 0
- sub edx,edx ; runningSum = 0
- forever:
- input string, 40
- atod string
- cmp eax,0
- je finish
- cmp eax,10
- jg invalid
- cmp eax,-10
- jl invalid
- cmp eax,0
- jg positive
- jl negative
- jmp jumpToMainLoop
- positive:
- inc ebx
- add edx,eax
- dtoa numaschar,eax
- output numaschar
- output positiveNumber
- output newline
- negative:
- add ecx,1
- dtoa numaschar,eax
- output numaschar
- output negativeNumber
- output newline
- invalid:
- dtoa numaschar,eax
- output numaschar
- output rejected
- output newline
- finish:
- dtoa numPosaschar, ebx
- dtoa numNegaschar, ecx
- dtoa sumasChar, edx
- output numberOfPos
- output numPosaschar
- output newline
- output numberOfNeg
- output numNegaschar
- output newline
- output runningSum
- output sumasChar
- output newline
- INVOKE ExitProcess, 0
- PUBLIC _start
- END
- jumpToMainLoop:
- jmp forever
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement