GIDForums  

Go Back   GIDForums > Computer Programming Forums > Assembly Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Apr-2009, 11:10
king-gideon king-gideon is offline
New Member
 
Join Date: Apr 2009
Posts: 1
king-gideon is on a distinguished road

Change all the negative elements in an array to zero


I need to change all the negative elements in an array to zero and print out the new array. Example: 1,2,3,-5,6,-7 would become 1,2,3,0,6,0. I tried writing this and it's not working.

Code:
.model small .stack 100h .data DEC_SIZE EQU 5 RES DB DEC_SIZE DUP('0') TEMP DW ? array dw 1,2,3,-5,6,-6 .code start:mov cx,6 mov bx,array cmp [bx],0 jnl Mark mov [bx],0 Mark: add bx,2 cmp [bx],0 jnl omark cmp[bx],0 omark: LOOP Mark mov bx,array MOV AX,[bx] MOV CX,10 MOV RES+DEC_SIZE,'$' MOV BX,OFFSET RES+DEC_SIZE CYCLE: DEC BX XOR DX,DX DIV CX ADD DL,'0' MOV [BX],DL CMP BX,OFFSET RES JNE CYCLE MOV AH,09 LEA DX,RES INT 21H mov cx,6 ft: mov cx,TEMP MOV AX,[bx] MOV CX,10 MOV RES+DEC_SIZE,'$' MOV BX,OFFSET RES+DEC_SIZE xCYCLE: DEC BX XOR DX,DX DIV CX ADD DL,'0' MOV [BX],DL CMP BX,OFFSET RES JNE xCYCLE MOV AH,09 LEA DX,RES INT 21H mov cx,temp loop ft ret End Start
  #2  
Old 07-Apr-2009, 16:29
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Change all the negative elements in an array to zero


What OS and compiler are you using.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:48.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.