x86-16

What is the purpose of the reserved/undefined bit in the flag register?

為{幸葍}努か 提交于 2019-12-10 06:19:26
问题 In the flag register of Z80, 8080, 8085, and 8086 processors, what is the purpose of bits 1, 3, 5, which are documented as "reserved" or "undefined"? 回答1: These bits are unused; that is, no instruction explicitly sets them to any value. The designers decided that 5/6 flags was enough, and they just left the remaining bits of the flags register unused. They are documented as being "undefined" because it is not possible to know in advance which value will they have after any of the instructions

Why does CMP (compare) sometimes sets a Carry Flag in 8086 assembly?

冷暖自知 提交于 2019-12-10 03:21:10
问题 I've been reading around and with the 8086 Instruction Set, it says that a CMP (compare) can set the Carry Flag. I understand that a compare subtracts two operands but I was wondering if anyone can provide an example when that is the case. I just can't grasp the idea of adding a number and a negative number will set the carry flag. I've read into the borrow flag but I just needed an example to clarify my understanding of a compare instruction. Also, I understand that if 3 - 5 = -2 would set

ADC instruction in ASM 8086

十年热恋 提交于 2019-12-09 14:54:10
问题 When I use ADC for exmaple: AL = 01 and BL = 02, and CF = 1 when I make this: ADC AL,BL Will AL be 3 or 4 ? (with the CF addition or without?) 回答1: Few things about the 8086 ADC instruction: Syntax: adc dest, src dest: memory or register src: memory, register, or immediate Action: dest = dest + src + CF Clearly the action says the Carry Flag ( CF ) will be included in the addition so the result will be 4 not 3 . 回答2: It is no different than adding in base 10. 99 +11 9+1 is zero carry the 1 9

How to pass/retrieve DOS command-line parameters in a 16-bit assembly program?

旧城冷巷雨未停 提交于 2019-12-09 06:27:26
问题 I am writing some little tools for MS-DOS. Now I'm writing a Shutdown.com , like for Windows XP and greater. I have already written the entire code, now I just need to pass the argument from DOS. I need to pass the parameters "-r" to reboot and "-s" to shutdown. How can I do it? I'm using TASM(Turbo Assembler 4.1) on Windows 98 to link and compile. I'm looking for a very simple way to do it, and if possible, still a .COM program. I'm looking exactly like the ARGV and ARGC from C language, but

Generating a random number within range of 0-9 in x86 8086 Assembly

冷暖自知 提交于 2019-12-09 06:04:03
问题 First of all, I am very new to 8086 Assembly and it has been pretty difficult for me the grab the knowledge. Nevertheless, I'll do my best. I have been trying to write a code to generate a random number within range of 0-9. After looking into several examples and suggestion, this is what I ended up with. I did not apply any mathematical function on the retrieved clock count, for simplicity and also I thought it was unnecessary. I ended up with, for some reasons, generating certain number like

What happens in the x86 architecture when an interrupt occurs?

*爱你&永不变心* 提交于 2019-12-08 23:51:52
问题 I'm studying x86 and Real Time Systems, and I have a question, that is: Which steps x86 follows to handle any interrupt ? 回答1: When an interrupt occurs, the CPU does the following: Push the current address (contents of the Instruction Pointer) onto the stack; also, push the processor flags (but not all the other processor registers) Jump to the address of the ISR (Interrupt Service Routine), which is specified in the Interrupt Descriptor Table. The ISR should do the following: Push any

8086 assembly - divide overflow

江枫思渺然 提交于 2019-12-08 12:28:53
问题 I try to make a simple division in assembly but I get "Divide overflow" error. My simple code: cs:sum and cs:num is a byte variable. (db) mov ax, word ptr cs:sum mov cl, 10 xor dx,dx div cl ; divide by 10 mov cs:num, ah ; ger rightest Not sure why - but as I say - I fail to devide properly. So do you know what is that problem and how to solve it? thanks ! (I'm using cs deference because that's a TSR program) 回答1: For this to cause a division exception mov ax, word ptr cs:sum mov cl, 10 div cl

How do I access double pointer from C code in ASM's stack

混江龙づ霸主 提交于 2019-12-08 09:06:31
问题 I have a main.c function which has the following statement: int initarr(int**arr, int n, int (*initfunc)(int)); Then I call the function in c like that: success = initarr(&arr, n, getNum); The question is, in assembly code, in MODEL SMALL , the first argument in the function above will be in the memory as WORD or DWORD ? In other words, when I write the code, will this work: PUSH BP MOV BP,SP PUSH DI MOV DI, WORD PTR[BP+4] ; DI will hold &arr. And now DI will hold arr's address. If it is true

how to change flags manually (in assembly code) for 8086?

余生颓废 提交于 2019-12-08 06:09:22
问题 Is there any way to change every flag manually? Or do you have to use a command with a result that you know will change them? Basically I'm working with the command RCL , and I don't want to get 1 at the begining, so I want to change the CF to 0, and I know that I can use commands like: mov al, 0 shl al, 1 But I want to know if there is any other way to do that, without the use of another commands result. I would also want to know whether the way you may show me, can also be used to change

What does “13, 10” mean in “DB 13, 10, 'hello world', 0”?

允我心安 提交于 2019-12-08 05:31:59
问题 I've been typing DB 13, 10, 'hello world', 0 for a long time without wondering what the 13, the 10 and the 0 were for. I recently noticed that doing: PTHIS DB 'hello world', 0 produced the same result, so I'm wondering what the first parameters are for and whether is a good idea to simply write it this way. Could someone write a quick explanation on this? (I suppose string declarations would be the topic) 回答1: It's the ASCII CR/LF (carriage return/line feed) sequence, used for advancing to