| | |
divide overflow problem
![]() |
•
•
Join Date: Jul 2008
Posts: 10
Reputation:
Solved Threads: 0
Assembly Syntax (Toggle Plain Text)
MOV AH,DAY DIV DIVISOR CMP Al,'0' JE WEEK_ JMP NOT_WEEK_
that is my code that tries to find out if the "DAY" is divisible by "7", which is the DIVISOR..
i initialized them as..
Assembly Syntax (Toggle Plain Text)
DAY DB 1 DIVISOR DB 7
when the "day" is divisible by 7, a 'divide oveflow' occurs..
how do i get this right? thanks
--there's a meaning in everything--
0
#2 Oct 18th, 2009
Try this:
Assembly Syntax (Toggle Plain Text)
MOV AL, DAY CBW DIV DIVISOR
while (CPU is present) {some assembly required}
0
#3 Oct 19th, 2009
This may make your issue more obvious...
You needed to specfy a data type snce you're using a memory reference
; It's a decimal response not an ASCII '0'
; Note: AH is day of week (0...6)
; AL is week # (0..N)
Assembly Syntax (Toggle Plain Text)
Quotient : Remainder = Dividend / Divisor AL : AH = AX / (8-bit) AX : DX = DX:AX / (16-bit) EAX : EDX = EDX:EAX /(32-bit)
Assembly Syntax (Toggle Plain Text)
MOV AH,DAY CBW ; AX = Day DIV DIVISOR ; Byte ptr Divisor ;;;; WRONG CMP Al,'0'
; Note: AH is day of week (0...6)
; AL is week # (0..N)
Last edited by wildgoose; Oct 19th, 2009 at 12:08 am.
•
•
Join Date: Jul 2008
Posts: 10
Reputation:
Solved Threads: 0
0
#4 21 Days Ago
I just would like to ask, what is the function of the 'CBW'?
Does it replace the
CMP al,'0' part?
I am really confused, since it does not seem to pass through the WEEK_:
Here's my code;
really, thanks a lot. Still hoping for your help. Thanks again.
Does it replace the
CMP al,'0' part?
I am really confused, since it does not seem to pass through the WEEK_:
Here's my code;
Assembly Syntax (Toggle Plain Text)
;increment the day (since it has to go first, ;to agree with my code I first made) INC DAY MOV AH,DAY ;I have to subtract 1 so that I will get the current day number SUB AH, 1 CBW DIV DIVISOR ;jumps to the WEEK_ function ;which summarizes the inventory for the week JE WEEK_ ;jumps to the NOT_WEEK_ function ;which makes it program loop until the sales reach zero JMP NOT_WEEK_
really, thanks a lot. Still hoping for your help. Thanks again.
--there's a meaning in everything--
0
#5 17 Days Ago
CBW - Convert Byte to Word
Sign extends the byte in AL into the word in AX.
Sign extension is merely copying the sign bit into the rest
of a datatype when a signed value is moved into a larger
datatype.
When it is a byte being copied into a word, the value of bit 7
is copied into the 8 MSBs of the high byte of the word.
so 80 becomes FF80,
and 7F becomes 007F.
Sign extends the byte in AL into the word in AX.
Sign extension is merely copying the sign bit into the rest
of a datatype when a signed value is moved into a larger
datatype.
When it is a byte being copied into a word, the value of bit 7
is copied into the 8 MSBs of the high byte of the word.
so 80 becomes FF80,
and 7F becomes 007F.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
![]() |
Similar Threads
- Why did I still get the error "Divide overflow" (Assembly)
- divide overflow issue (Assembly)
- DATASTAR DATABASE divide overflow (Assembly)
- divide overflow??? (Assembly)
- Won't load past startup; Divide overflow error? (Troubleshooting Dead Machines)
Other Threads in the Assembly Forum
- Previous Thread: Detect Multicore processors
- Next Thread: Use string to call variable
| Thread Tools | Search this Thread |





